GetWccs¶
-
GetWccs
()¶
A graph method that returns all weakly connected components in a graph.
Parameters:
None
Return value:
- CnComV:
TCnComV
, a vector of connected components Vector of all weakly-connected components. Each component consists of a TIntV vector of node ids.
- CnComV:
The following example shows how to calculate all weakly-connected components in
TNGraph
, TUNGraph
, and TNEANet
:
import snap
Graph = snap.GenRndGnm(snap.TNGraph, 100, 1000)
Components = Graph.GetWccs()
for CnCom in Components:
print("Size of component: %d" % CnCom.Len())
UGraph = snap.GenRndGnm(snap.TUNGraph, 1000, 50)
Components = UGraph.GetWccs()
for CnCom in Components:
print("Size of component: %d" % CnCom.Len())
Network = snap.GenRndGnm(snap.TNEANet, 1000, 300)
Components = Network.GetWccs()
for CnCom in Components:
print("Size of component: %d" % CnCom.Len())