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

Method test_paths

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

Source from the content-addressed store, hash-verified

213 print "pattern.graph.Graph._adjacency"
214
215 def test_paths(self):
216 # Assert node paths.
217 g = self.g.copy()
218 self.assertEqual(g.paths("a", "c"), g.paths(g["a"], g["c"]))
219 self.assertEqual(g.paths("a", "c"), [[g["a"], g["b"], g["c"]]])
220 self.assertEqual(g.paths("a", "c", length=2), [])
221 # Assert node shortest paths.
222 g.add_edge("a", "c")
223 self.assertEqual(g.paths("a", "c", length=2), [[g["a"], g["c"]]])
224 self.assertEqual(g.shortest_path("a", "c"), [g["a"], g["c"]])
225 self.assertEqual(g.shortest_path("c", "a"), [g["c"], g["a"]])
226 self.assertEqual(g.shortest_path("c", "a", directed=True), None)
227 g.remove(g.edge("a", "c"))
228 g.add_node("d")
229 self.assertEqual(g.shortest_path("a", "d"), None)
230 self.assertEqual(g.shortest_paths("a")["b"], [g["a"], g["b"]])
231 self.assertEqual(g.shortest_paths("a")["c"], [g["a"], g["b"], g["c"]])
232 self.assertEqual(g.shortest_paths("a")["d"], None)
233 self.assertEqual(g.shortest_paths("c", directed=True)["a"], None)
234 g.remove(g["d"])
235 print "pattern.graph.Graph.paths()"
236 print "pattern.graph.Graph.shortest_path()"
237 print "pattern.graph.Graph.shortest_paths()"
238
239 def test_eigenvector_centrality(self):
240 # Assert eigenvector centrality.

Callers

nothing calls this directly

Calls 8

pathsMethod · 0.80
shortest_pathMethod · 0.80
shortest_pathsMethod · 0.80
copyMethod · 0.45
add_edgeMethod · 0.45
removeMethod · 0.45
edgeMethod · 0.45
add_nodeMethod · 0.45

Tested by

no test coverage detected