igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Question about the functions induced.subgraph() and cluster


From: Gábor Csárdi
Subject: Re: [igraph] Question about the functions induced.subgraph() and clusters()
Date: Fri, 21 Mar 2014 13:42:45 -0400

On Fri, Mar 21, 2014 at 10:57 AM, address@hidden <address@hidden> wrote:
Thank you
 
If I want to generate a subgraph which contains all the vertices and just delete the edges to make the vertices (which were meant to be delete) to be isolate,
then which command could I use?
This is not an induced subgraph. You can use subgraph.edges.
Or is there any command can be used to generate a subgraph without changing the vertice ids?
No, there isn't and there can't be by definition. You can use symbolic vertex names (i.e. a 'name' vertex attribute) instead of internal ids. Depending on what you do, it might be cumbersome because you'll need convert internal ids to names sometimes.

Gabor
 
 
best
Xueming
 

 
Date: 2014-03-21 22:17
Subject: Re: [igraph] Question about the functions induced.subgraph() and clusters()
Internal vertex ids change if you change the graph. E.g.

set.seed(42)
ga <- erdos.renyi.game(1000, 1500, type = "gnm", directed=TRUE)
ga
wcca <- clusters(ga, mode="weak")
for (i in 1:10) {
   largest_wcc_va <- which(wcca$membership == which.max(wcca$csize))
   ga <- induced.subgraph(ga, largest_wcc_va)
}
ga

Gabor



On Fri, Mar 21, 2014 at 10:00 AM, address@hidden <address@hidden> wrote:
 
Hi!
 
It is known to us that the maximal weakly connected component of a connected nework is itself. Just like the code below shows that the elements of Siz_wcc never change.
 
        ga <- erdos.renyi.game(1000, 1500, type = "gnm", directed=TRUE);
        Siz_wcc <- rep(0,10) 
         for(i in 1:10)
         {
             wcca <- clusters(ga, mode="weak")
             largest_wcc_va <- which(wcca$membership == which.max(wcca$csize))
             Siz_wcc[i] <- length(largest_wcc_va)     
             ga <- induced.subgraph(ga, largest_wcc_va, impl="copy_and_delete")
         }
>  Siz_wcc
[1] 936 936 936 936 936 936 936 936 936 936
 
Given two networks ga and gb, if network ga is exactly the same with network gb, then the elements in Siz_wcca and Siz_wccb are also expected to be invariant. But Siz_wcca and Siz_wccb decrease to 1 in the end. How could this happen?
 
         gb <- erdos.renyi.game(1000, 1500, type = "gnm", directed=TRUE);
         ga <- gb          
         Siz_wcca <- rep(0,10) 
         Siz_wccb <- rep(0,10) 
         for(i in 1:10)
         {
             wcca <- clusters(ga, mode="weak")
             largest_wcc_va <- which(wcca$membership == which.max(wcca$csize))
             Siz_wcca[i] <- length(largest_wcc_va)     
             gb <- induced.subgraph(gb, largest_wcc_va, impl="copy_and_delete")
 
             wccb <- clusters(gb, mode="weak")
             largest_wcc_vb <- which(wccb$membership == which.max(wccb$csize))
             Siz_wccb[i] <- length(largest_wcc_vb)
             ga <- induced.subgraph(ga, largest_wcc_vb, impl="copy_and_delete")
          }
> Siz_wcca
[1] 933 854 756 615 331   3   1   1   1   1
> Siz_wccb
[1] 933 845 722 521  46   1   1   1   1   1
 
best
Xueming
 


_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help



_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

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