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

Method shortest_paths

pattern/graph/__init__.py:444–452  ·  view source on GitHub ↗

Returns a dictionary of nodes, each linked to a list of nodes (shortest path).

(self, node, heuristic=None, directed=False)

Source from the content-addressed store, hash-verified

442 return None
443
444 def shortest_paths(self, node, heuristic=None, directed=False):
445 """ Returns a dictionary of nodes, each linked to a list of nodes (shortest path).
446 """
447 if not isinstance(node, Node):
448 node = self[node]
449 p = nodedict(self)
450 for id, path in dijkstra_shortest_paths(self, node.id, heuristic, directed).iteritems():
451 p[self[id]] = path and [self[id] for id in path] or None
452 return p
453
454 def eigenvector_centrality(self, normalized=True, reversed=True, rating={}, iterations=100, tolerance=0.0001):
455 """ Calculates eigenvector centrality and returns a node => weight dictionary.

Callers 1

test_pathsMethod · 0.80

Calls 3

nodedictClass · 0.85
dijkstra_shortest_pathsFunction · 0.85
iteritemsMethod · 0.80

Tested by 1

test_pathsMethod · 0.64