Fills HopCntV with pairs (hop distance from StartNId, number of nodes at that hop distance). The function returns the number of different hop distances reachable from StartNId.
Parameters:
A Snap.py graph or a network.
Starting node id.
Vector of (hop distance, number of nodes at that distance) pairs.
Indicates whether the edges should be considered directed (True) or undirected (False).
Return value:
Number of different hop distances reachable from StartNId, including self-loops.
The following example shows how to obtain number of nodes for each hop distance from node 1 in TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
NodeVec = snap.TIntPrV()
snap.GetNodesAtHops(Graph, 1, NodeVec, True)
for item in NodeVec:
print "%d, %d" % (item.GetVal1(), item.GetVal2())
UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
NodeVec = snap.TIntPrV()
snap.GetNodesAtHops(UGraph, 1, NodeVec, False)
for item in NodeVec:
print "%d, %d" % (item.GetVal1(), item.GetVal2())
Network = snap.GenRndGnm(snap.PNEANet, 100, 1000)
NodeVec = snap.TIntPrV()
snap.GetNodesAtHops(Network, 1, NodeVec, True)
for item in NodeVec:
print "%d, %d" % (item.GetVal1(), item.GetVal2())