MCPcopy Index your code
hub / github.com/clips/pattern / test_graph_edges

Method test_graph_edges

test/test_graph.py:181–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

179 print "pattern.graph.Graph.add_node()"
180
181 def test_graph_edges(self):
182 # Assert graph edges.
183 g = self.g.copy()
184 v1 = g.add_edge("d", "e") # Automatically create Node(d) and Node(e).
185 v2 = g.add_edge("d", "e") # Yields existing edge.
186 v3 = g.add_edge("e", "d") # Opposite direction.
187 self.assertEqual(v1, v2)
188 self.assertEqual(v2, g.edge("d", "e"))
189 self.assertEqual(v3, g.edge("e", "d"))
190 self.assertEqual(g["d"].links.edge(g["e"]), v2)
191 self.assertEqual(g["e"].links.edge(g["d"]), v3)
192 g.remove(g["d"])
193 g.remove(g["e"])
194 # Edges d->e and e->d should now be removed automatically.
195 self.assertEqual(len(g.edges), 2)
196 print "pattern.graph.Graph.add_edge()"
197
198 def test_cache(self):
199 # Assert adjacency cache is flushed when nodes, edges or direction changes.

Callers

nothing calls this directly

Calls 5

lenFunction · 0.85
copyMethod · 0.45
add_edgeMethod · 0.45
edgeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected