Returns the length of the shortest path from node SrcNId to node DstNId.
Parameters:
A Snap.py graph or a network.
Node id for source node.
Node id for destination node.
Indicates whether the edges should be considered directed or undirected.
Return value:
Number of edges traversed in shortest path from SrcNId to DstNId.
The following example shows how to find shortest path for nodes in TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
Length = GetShortPath(Graph, 1, 100)
print "Shortest Path from node 1 to node 100 is %d edges" % Length
UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
Length = GetShortPath(UGraph, 1, 100)
print "Shortest Path from node 1 to node 100 is %d edges" % Length
Network = snap.GenRndGnm(snap.PNEANet, 100, 1000)
Length = GetShortPath(Network, 1, 100)
print "Shortest Path from node 1 to node 100 is %d edges" % Length