igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Connected Components


From: Gábor Csárdi
Subject: Re: [igraph] Connected Components
Date: Thu, 5 Nov 2009 15:09:47 +0100

Hi,

On Thu, Nov 5, 2009 at 2:44 PM, Michael Knudsen <address@hidden> wrote:
> Hello,
>
> I have a graph, and I want to plot only the biggest connected
> component, but something appears not to be working as it is supposed
> to do. First I read in my data:
>
>> g <- graph(scan("protein_data.txt"),directed=F)
> Read 8960 items
>> g <- simplify(g)
>
> I then use the clusters function to get the clusters:
>
>> g_clusters <- clusters(g)
>> which(g_clusters$csize == max(g_clusters$csize))
> [1] 3
>
> Hence cluster number three is the biggest. Since counting starts at 0
> in igraph, this means that the connected component consists of the
> vertices:
>
> selected_vertices <- V(g)[which(g_clusters$membership == 2)]

the infamous 0-1 catch. This should be

selected_vertices <- V(g)[which(g_clusters$membership == 2)-1]

or simply

selected_vertices <- which(g_clusters$membership == 2)-1

Gabor

[...]


-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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