igraph-help
[Top][All Lists]
Advanced

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

[igraph] delete connected vertices of to-be-deleted vertices


From: Cesar Caballero
Subject: [igraph] delete connected vertices of to-be-deleted vertices
Date: Thu, 29 Oct 2015 02:03:30 +0100 (CET)

Hi all,

My network is a simple undirected graph of 101 vertices with edges between 
neighbouring vertices.
I created this network as

G <- graph.adjacency(rbind(getD1d(100),matrix(0,1,100)),mode='undirected')
V(G)$name <- V(G) 

where, e.g. getD1d(5) is defined as

> getD1d(5)
     [,1] [,2] [,3] [,4] [,5]
[1,]   -1    1    0    0    0
[2,]    0   -1    1    0    0
[3,]    0    0   -1    1    0
[4,]    0    0    0   -1    1


For a fused lasso regression problem, I need to first delete all edges of G 
that satisfy an 
equality condition, yielding a new graph G2. For instance, let X be a vector of 
100 integer 
numbers between 1 and 5, let's delete those that are equal to 5.

> X <- sample.int(5,100,replace=TRUE)
> G2 <- delete.edges(G,which(X == 5))

After this step, I must delete all vertices that satisfy another condition 
(e.g. which(X2 == 'a'), 
but also ALL of THEIR CONNECTED VERTICES (considering the edges removed in the 
previous step).

To my best knowledge, I can use delete.vertices to remove the first set of 
vertices, i.e. something like
X2 <- letters[sample(5,101,replace=TRUE)]
delete.vertices(G2,which(X2 == 'a')

But, does this step ALSO remove THEIR CONNECTED VERTICES? If not, how can I 
achieve this?

Thanks very much in advance for your help.

Best wishes,
Cesar



----------------------------------------------------------------------
Cesar Caballero
MRI engineer
www.bcbl.eu 

Twitter: @caballerogaudes
www.researchgate.net/profile/Cesar_Caballero2

Legal disclaimer/Aviso legal/Lege-oharra: www.bcbl.eu/legal-disclaimer



reply via email to

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