Computes the number of shared neighbors between a pair of nodes NId1 and NId2. The node ids of the neighbors are stored in NbrV.
Parameters:
A Snap.py graph or a network.
Node id of the first node.
Node id of the second node.
Shared neighbors between the two nodes. Neighbors are node IDs.
Return value:
The number of common neighbors between the pair of nodes.
The following example shows how to find the shared neighbors of two nodes in TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
Nbrs = snap.TIntV()
snap.GetCmnNbrs(Graph, 1, 10, Nbrs)
for NId in Nbrs:
print "node: %d" % NId
UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
Nbrs = snap.TIntV()
snap.GetCmnNbrs(UGraph, 1, 10, Nbrs)
for NId in Nbrs:
print "node: %d" % NId
Network = snap.GenRndGnm(snap.PNEANet, 100, 1000)
Nbrs = snap.TIntV()
snap.GetCmnNbrs(Network, 1, 10, Nbrs)
for NId in Nbrs:
print "node: %d" % NId