pysal.explore.spaghetti.generatetree

pysal.explore.spaghetti.generatetree(pred)[source]

Rebuild the shortest path from root origin to destination

Parameters:
pred : list

List of preceeding nodes for traversal route.

Returns:
tree : dict

key is root origin; value is root origin to destination.

Examples

>>> import pysal.explore.spaghetti as spgh
>>> from pysal.lib import examples
>>> ntw = spgh.Network(examples.get_path('streets.shp'))
>>> distance, pred = spgh.util.dijkstra(ntw, ntw.edge_lengths, 0)
>>> tree = spgh.util.generatetree(pred)
>>> tree[3]
[23, 22, 20, 19, 170, 2, 0]