Note
This page is a draft and under revision.
Note
This function is not yet supported.
Computes the average clustering coefficient, as well as the number of open and closed triads in the graph, as defined in Watts and Strogatz, Collective dynamics of ‘small-world’ networks.
Parameters:
A Snap.py graph or a network
The vector of pairs (degree, avg. clustering coefficient of nodes of that degree)
The closed triads in the graph
The open triads in the graph
If !=-1 then compute clustering coefficient only for a random sample of SampleNodes nodes
Return value:
The average clustering coefficient
For more info see: http://en.wikipedia.org/wiki/Watts_and_Strogatz_model
The following example shows how to compute the in degree for nodes in TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
DegToCCfV = snap.TFltPrV()
# There is no SNAP type for 64-bit ints, so use two argument version of function instead
#ClosedTriads = snap.TInt()
#OpenTriads = snap.TInt()
#print snap.GetClustCf(Graph, DegToCCfV, ClosedTriads, OpenTriads)
print snap.GetClustCf(Graph, DegToCCfV)
for item in DegToCCfV:
print item.GetVal1(), item.GetVal2()
#print ClosedTriads
#print OpenTriads
Graph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
DegToCCfV = snap.TFltPrV()
# There is no SNAP type for 64-bit ints, so use two argument version of function instead
#ClosedTriads = snap.TInt()
#OpenTriads = snap.TInt()
#print snap.GetClustCf(Graph, DegToCCfV, ClosedTriads, OpenTriads)
print snap.GetClustCf(Graph, DegToCCfV)
for item in DegToCCfV:
print item.GetVal1(), item.GetVal2()
#print ClosedTriads
#print OpenTriads
Graph = snap.GenRndGnm(snap.PNEANet, 100, 1000)
DegToCCfV = snap.TFltPrV()
# There is no SNAP type for 64-bit ints, so use two argument version of function instead
#ClosedTriads = snap.TInt()
#OpenTriads = snap.TInt()
#print snap.GetClustCf(Graph, DegToCCfV, ClosedTriads, OpenTriads)
print snap.GetClustCf(Graph, DegToCCfV)
for item in DegToCCfV:
print item.GetVal1(), item.GetVal2()
#print ClosedTriads
#print OpenTriads