MCPcopy
hub / github.com/networkx/networkx / test_digraphs

Method test_digraphs

networkx/tests/test_convert.py:71–100  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

69 pytest.raises(nx.NetworkXError, to_networkx_graph, "a")
70
71 def test_digraphs(self):
72 for dest, source in [
73 (to_dict_of_dicts, from_dict_of_dicts),
74 (to_dict_of_lists, from_dict_of_lists),
75 ]:
76 G = cycle_graph(10)
77
78 # Dict of [dicts, lists]
79 dod = dest(G)
80 GG = source(dod)
81 assert nodes_equal(sorted(G.nodes()), sorted(GG.nodes()))
82 assert edges_equal(sorted(G.edges()), sorted(GG.edges()))
83 GW = to_networkx_graph(dod)
84 assert nodes_equal(sorted(G.nodes()), sorted(GW.nodes()))
85 assert edges_equal(sorted(G.edges()), sorted(GW.edges()))
86 GI = nx.Graph(dod)
87 assert nodes_equal(sorted(G.nodes()), sorted(GI.nodes()))
88 assert edges_equal(sorted(G.edges()), sorted(GI.edges()))
89
90 G = cycle_graph(10, create_using=nx.DiGraph)
91 dod = dest(G)
92 GG = source(dod, create_using=nx.DiGraph)
93 assert sorted(G.nodes()) == sorted(GG.nodes())
94 assert sorted(G.edges()) == sorted(GG.edges())
95 GW = to_networkx_graph(dod, create_using=nx.DiGraph)
96 assert sorted(G.nodes()) == sorted(GW.nodes())
97 assert sorted(G.edges()) == sorted(GW.edges())
98 GI = nx.DiGraph(dod)
99 assert sorted(G.nodes()) == sorted(GI.nodes())
100 assert sorted(G.edges()) == sorted(GI.edges())
101
102 def test_graph(self):
103 g = nx.cycle_graph(10)

Callers

nothing calls this directly

Calls 7

edgesMethod · 0.95
cycle_graphFunction · 0.90
nodes_equalFunction · 0.90
edges_equalFunction · 0.90
to_networkx_graphFunction · 0.90
nodesMethod · 0.80
edgesMethod · 0.45

Tested by

no test coverage detected