IsConnected (SWIG)ΒΆ

IsConnected(Graph)

Tests whether Graph is (weakly) connected.

Parameters:

  • Graph: graph (input)

    A Snap.py graph or a network.

Return value:

  • bool

    Returns True if the Graph is (weakly) connected, False otherwise.

The following example shows how to use IsConnected() for nodes in TNGraph, TUNGraph, and TNEANet:

import snap

Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
print(snap.IsConnected(Graph))

UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
print(snap.IsConnected(UGraph))

Network = snap.GenRndGnm(snap.PNEANet, 100, 1000)
print(snap.IsConnected(Network))