Finds the node ids of all the nodes that are at distance Hop from node StartNId and stores them in NIdV. The function returns the number of nodes found.
Parameters:
A Snap.py graph or a network.
Starting node id.
Distance from the starting node.
Node ids of nodes Hop distance away from StartNId.
Indicates whether the edges should be considered directed or undirected.
Return value:
The number of nodes at distance Hop from StartNId.
The following example shows how to get a vector of nodes at hop distance 2 away from start node 1 for nodes in TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
NodeVec = snap.TIntV()
snap.GetNodesAtHop(Graph, 1, 2, NodeVec, True)
for item in NodeVec:
print item
UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
NodeVec = snap.TIntV()
snap.GetNodesAtHop(UGraph, 1, 2, NodeVec, True)
for item in NodeVec:
print item
Network = snap.GenRndGnm(snap.PNEANet, 100, 1000)
NodeVec = snap.TIntV()
snap.GetNodesAtHop(Network, 1, 2, NodeVec, True)
for item in NodeVec:
print item