### from python2 to python3 > ok from command line

parent f1028f5b
 ... ... @@ -60,4 +60,4 @@ A quick introductory example: {'A': 'B', 'C': 'A', 'B': 'Y', 'Y': 'X', 'X': None, 'Z': 'X'} """ __import__('pkg_resources').declare_namespace(__name__) #__import__('pkg_resources').declare_namespace(__name__)
 ... ... @@ -63,7 +63,7 @@ def generate(num_nodes, num_edges, directed=False, weight_range=(1, 1)): random_graph = graph() # Nodes nodes = range(num_nodes) nodes = list(range(num_nodes)) random_graph.add_nodes(nodes) # Build a list of all possible edges ... ...
 ... ... @@ -429,7 +429,7 @@ def cut_value(graph, flow, cut): #max flow/min cut value calculation S = [] T = [] for node in cut.keys(): for node in list(cut.keys()): if cut[node] == 0: S.append(node) elif cut[node] == 1: ... ... @@ -481,7 +481,7 @@ def cut_tree(igraph, caps = None): N = N + 1 #predecessor function p = {}.fromkeys(range(N),0) p = {}.fromkeys(list(range(N)),0) p = None for s in range(1,N): ... ...
 ... ... @@ -64,7 +64,7 @@ def depth_first_search(graph, root=None, filter=null()): pre.append(node) # Explore recursively the connected component for each in graph[node]: if (each not in visited and filter(each, node)): if (each not in visited and list(filter(each, node))): spanning_tree[each] = node dfs(each) post.append(node) ... ... @@ -77,7 +77,7 @@ def depth_first_search(graph, root=None, filter=null()): # DFS from one node only if (root is not None): if filter(root, None): if list(filter(root, None)): spanning_tree[root] = None dfs(root) setrecursionlimit(recursionlimit) ... ... @@ -86,7 +86,7 @@ def depth_first_search(graph, root=None, filter=null()): # Algorithm loop for each in graph: # Select a non-visited node if (each not in visited and filter(each, None)): if (each not in visited and list(filter(each, None))): spanning_tree[each] = None # Explore node's connected component dfs(each) ... ... @@ -122,7 +122,7 @@ def breadth_first_search(graph, root=None, filter=null()): node = queue.pop(0) for other in graph[node]: if (other not in spanning_tree and filter(other, node)): if (other not in spanning_tree and list(filter(other, node))): queue.append(other) ordering.append(other) spanning_tree[other] = node ... ... @@ -134,7 +134,7 @@ def breadth_first_search(graph, root=None, filter=null()): # BFS from one node only if (root is not None): if filter(root, None): if list(filter(root, None)): queue.append(root) ordering.append(root) spanning_tree[root] = None ... ... @@ -144,7 +144,7 @@ def breadth_first_search(graph, root=None, filter=null()): # Algorithm for each in graph: if (each not in spanning_tree): if filter(each, None): if list(filter(each, None)): queue.append(each) ordering.append(each) spanning_tree[each] = None ... ...
 ... ... @@ -101,7 +101,7 @@ class digraph (basegraph, common, labeling): return [ a for a in self._edges() ] def _edges(self): for n, neighbors in self.node_neighbors.items(): for n, neighbors in list(self.node_neighbors.items()): for neighbor in neighbors: yield (n, neighbor) ... ...
 ... ... @@ -87,7 +87,7 @@ class graph(basegraph, common, labeling): @rtype: list @return: List of all edges in the graph. """ return [ a for a in self.edge_properties.keys() ] return [ a for a in list(self.edge_properties.keys()) ] def has_node(self, node): """ ... ...
 ... ... @@ -30,4 +30,4 @@ Base classes used to compose the the graph classes. The classes in this namespace should not be used directly. """ __import__('pkg_resources').declare_namespace(__name__) #__import__('pkg_resources').declare_namespace(__name__)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!