MCPcopy
hub / github.com/networkx/networkx / test_add_node

Method test_add_node

networkx/classes/tests/test_graph.py:637–654  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

635 G.__getitem__(["A"])
636
637 def test_add_node(self):
638 G = self.Graph()
639 G.add_node(0)
640 assert G.adj == {0: {}}
641 # test add attributes
642 G.add_node(1, c="red")
643 G.add_node(2, c="blue")
644 G.add_node(3, c="red")
645 assert G.nodes[1]["c"] == "red"
646 assert G.nodes[2]["c"] == "blue"
647 assert G.nodes[3]["c"] == "red"
648 # test updating attributes
649 G.add_node(1, c="blue")
650 G.add_node(2, c="red")
651 G.add_node(3, c="blue")
652 assert G.nodes[1]["c"] == "blue"
653 assert G.nodes[2]["c"] == "red"
654 assert G.nodes[3]["c"] == "blue"
655
656 def test_add_nodes_from(self):
657 G = self.Graph()

Callers

nothing calls this directly

Calls 1

add_nodeMethod · 0.95

Tested by

no test coverage detected