igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] ?????? ?????? how to find disconn ected components


From: Tam??s Nepusz
Subject: Re: [igraph] ?????? ?????? how to find disconn ected components
Date: Fri, 21 Jun 2013 16:07:33 +0200

> in fact, i have some big/large graphs, which return FALSE if i call 
> is_connected(). 
> I just want to know if they are disconnected, how many disconnected 
> components do they have.
Gabor has suggested using components() in a previous email, what's wrong with 
that? components() will give you a VertexClustering object where each cluster 
corresponds to a connected component of a vertex. You can then call len() on 
the VertexClustering object to get the number of components:

>>> g = Graph.Full(4) * 5
>>> len(g.components())
5

You can also index the result of g.components() as if it were a list to get the 
indices of the vertices in each of the components:

>>> comp = g.components()
>>> comp[0]
[0, 1, 2, 3]

-- 
T.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]