MCPcopy
hub / github.com/networkx/networkx / test_default_attribute

Method test_default_attribute

networkx/readwrite/tests/test_gexf.py:301–320  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

299 assert sorted(G.nodes()) == ["Hello", "Word"]
300
301 def test_default_attribute(self):
302 G = nx.Graph()
303 G.add_node(1, label="1", color="green")
304 nx.add_path(G, [0, 1, 2, 3])
305 G.add_edge(1, 2, foo=3)
306 G.graph["node_default"] = {"color": "yellow"}
307 G.graph["edge_default"] = {"foo": 7}
308 fh = io.BytesIO()
309 nx.write_gexf(G, fh)
310 fh.seek(0)
311 H = nx.read_gexf(fh, node_type=int)
312 assert sorted(G.nodes()) == sorted(H.nodes())
313 assert sorted(sorted(e) for e in G.edges()) == sorted(
314 sorted(e) for e in H.edges()
315 )
316 # Reading a gexf graph always sets mode attribute to either
317 # 'static' or 'dynamic'. Remove the mode attribute from the
318 # read graph for the sake of comparing remaining attributes.
319 del H.graph["mode"]
320 assert G.graph == H.graph
321
322 def test_serialize_ints_to_strings(self):
323 G = nx.Graph()

Callers

nothing calls this directly

Calls 4

add_nodeMethod · 0.95
add_edgeMethod · 0.95
nodesMethod · 0.95
edgesMethod · 0.95

Tested by

no test coverage detected