diff --git a/.travis.yml b/.travis.yml index f859cc4..5a906e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,7 @@ language: python python: - - "2.7" - - "3.3" - - "3.4" - - "3.5" - - "3.6" + - "3.8" + - "3.9" before_install: - pip install coveralls - pip install codecov diff --git a/postman_problems/examples/star/rpp_star.py b/postman_problems/examples/star/rpp_star.py index 9e986f0..fae541a 100644 --- a/postman_problems/examples/star/rpp_star.py +++ b/postman_problems/examples/star/rpp_star.py @@ -20,7 +20,7 @@ def create_star_graph(n_nodes=10, ring=True): """ graph = nx.MultiGraph() node_names = list(string.ascii_lowercase)[:n_nodes] - graph.add_star(node_names) + nx.add_star(graph, node_names) nx.set_edge_attributes(graph, 10, 'distance') nx.set_edge_attributes(graph, 1, 'required') nx.set_edge_attributes(graph, 'solid', 'style') diff --git a/postman_problems/solver.py b/postman_problems/solver.py index 890284e..2519c33 100644 --- a/postman_problems/solver.py +++ b/postman_problems/solver.py @@ -51,7 +51,7 @@ def rpp(edgelist_filename, start_node=None, edge_weight='distance', verbose=Fals logger_rpp.info('Find min weight matching using blossom algorithm') g_odd_complete = create_complete_graph(odd_node_pairs_shortest_paths, flip_weights=True) - odd_matching = dedupe_matching(nx.algorithms.max_weight_matching(g_odd_complete, True)) + odd_matching = nx.algorithms.max_weight_matching(g_odd_complete, True) logger_rpp.info('add the min weight matching edges to g') g_aug = add_augmenting_path_to_graph(g_req, odd_matching) @@ -94,7 +94,7 @@ def cpp(edgelist_filename, start_node=None, edge_weight='distance', verbose=Fals g_odd_complete = create_complete_graph(odd_node_pairs_shortest_paths, flip_weights=True) logger_cpp.info('Find min weight matching using blossom algorithm') - odd_matching = dedupe_matching(nx.algorithms.max_weight_matching(g_odd_complete, True)) + odd_matching = nx.algorithms.max_weight_matching(g_odd_complete, True) logger_cpp.info('add the min weight matching edges to g') g_aug = add_augmenting_path_to_graph(g, odd_matching) diff --git a/postman_problems/viz.py b/postman_problems/viz.py index 3bb725a..5cb431e 100644 --- a/postman_problems/viz.py +++ b/postman_problems/viz.py @@ -51,8 +51,8 @@ def add_pos_node_attribute(graph, origin='bottomleft'): for node_id in graph.nodes(): try: # dividing by arbitrary number to make pos appear as required type: double - graph.node[node_id]['pos'] = "{},{}!".format(ori['X']*graph.node[node_id]['X']/100, - ori['Y']*graph.node[node_id]['Y']/100) + graph.nodes[node_id]['pos'] = "{},{}!".format(ori['X']*graph.nodes[node_id]['X']/100, + ori['Y']*graph.nodes[node_id]['Y']/100) except KeyError as e: print(e) print('No X, Y coordinates found for node: {}'.format(node_id)) @@ -114,7 +114,7 @@ def convert_networkx_graph_to_graphiz(graph, directed=False): # add nodes and their attributes to graphviz object for n in graph.nodes(): - n_attr = {k: str(v) for k, v in graph.node[n].items()} + n_attr = {k: str(v) for k, v in graph.nodes[n].items()} G.attr('node', n_attr) G.node(str(n), str(n)) @@ -229,7 +229,7 @@ def make_circuit_images(circuit, graph, outfile_dir, format='png', engine='neato # Start w a blank (OK, opaque) canvas for e in graph_white.edges(keys=True): - graph_white.node[e[0]]['color'] = graph_white.node[e[1]]['color'] = '#eeeeee' + graph_white.nodes[e[0]]['color'] = graph_white.nodes[e[1]]['color'] = '#eeeeee' graph_white[e[0]][e[1]][e[2]]['color'] = '#eeeeee' graph_white[e[0]][e[1]][e[2]]['label'] = '' @@ -238,8 +238,8 @@ def make_circuit_images(circuit, graph, outfile_dir, format='png', engine='neato # adding node colors eid = e[3]['id'] - graph_white.node[e[0]]['color'] = 'black' - graph_white.node[e[1]]['color'] = 'red' # will get overwritten at next step + graph_white.nodes[e[0]]['color'] = 'black' + graph_white.nodes[e[1]]['color'] = 'red' # will get overwritten at next step # adding edge colors and attributes key = e[2] diff --git a/setup.py b/setup.py index 8cfbb4b..aca2e72 100644 --- a/setup.py +++ b/setup.py @@ -47,10 +47,10 @@ def read(fname): 'rural_postman_star=postman_problems.examples.star.rpp_star:main' ] }, - python_requires='>=2.7', + python_requires='>=3.7.1', install_requires=[ 'pandas', - 'networkx==2.0' + 'networkx>=2.0' ], extras_require={ 'viz': ['imageio', 'matplotlib', 'graphviz', 'tqdm'],