MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / to_networkx

Function to_networkx

numpy_ml/tests/test_utils.py:241–253  ·  view source on GitHub ↗

Convert my graph representation to a networkx graph

(G)

Source from the content-addressed store, hash-verified

239
240
241def to_networkx(G):
242 """Convert my graph representation to a networkx graph"""
243 G_nx = nx.DiGraph() if G.is_directed else nx.Graph()
244 V = list(G._V2I.keys())
245 G_nx.add_nodes_from(V)
246
247 for v in V:
248 fr_i = G._V2I[v]
249 edges = G._G[fr_i]
250
251 for edge in edges:
252 G_nx.add_edge(edge.fr, edge.to, weight=edge._w)
253 return G_nx
254
255
256def test_all_paths(N=1):

Callers 4

test_all_pathsFunction · 0.85
test_random_DAGFunction · 0.85
test_is_acyclicFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected