Darwin Help

Back to Index

ShortestPath

Function ShortestPath - shortest path from one node to all others

Calling Sequence  ShortestPath(g,i,excl)
Parameters
NameTypeDescription

g Graphgiven graph
i anythingstarting node
excl set(optional) excluded node set
Return Type  list([posint, numeric])
Synopsis Compute the shortest path from node i to every connected node in g. It is assumed that a non-negative numeric label on an Edge is the length of the edge, that is the distance between the corresponding nodes. "excl" is the set of nodes not to be considered and defaults to {}.
Examples
> g := Graph( Edges(Edge(1.2,1,2),Edge(2,1,4),Edge(3,1,5),Edge(4,2,3),Edge(5,3,4)),Nodes(1,2,3,4,5));
g := Graph(Edges(Edge(1.2000,1,2),Edge(2,1,4),Edge(3,1,5),Edge(4,2,3),Edge(5,3,4
)),Nodes(1,2,3,4,5))
> ShortestPath(g,1);
[[1, 0], [2, 1.2000], [3, 5.2000], [4, 2], [5, 3]]


See also BipartiteGraph,   Clique,   DrawGraph,   Edge,   EdgeComplement,   Edges,   FindConnectedComponents,   Graph,   Graph_Rand,   InduceGraph,   MaxCut,   MaxEdgeWeightClique,   MST,   Nodes,   Path,   RegularGraph,   TetrahedronGraph,   VertexCover