igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] simple subgraph problem


From: Csardi Gabor
Subject: Re: [igraph] simple subgraph problem
Date: Wed, 3 Sep 2008 17:13:18 +0200
User-agent: Mutt/1.5.9i

Hmmm, my interpretation is that she wants only the vertices that 
have at least one adjacent green edge.... so this would be

g <- erdos.renyi.game(100, 5/100)
E(g)$color <- sample( c("green", "red"), ecount(g), rep=TRUE)

and then

g2 <- subgraph(g, V(g) [ adj(E(g) [ color=="green" ]) ])

plus, if you want to keep the green edges only, then

g2 <- delete.edges(g2, E(g2)[ color != "green" ])

G.

On Wed, Sep 03, 2008 at 04:06:39PM +0100, Tamas Nepusz wrote:
> Hi,
> 
> >I have a network with multiple edges (different color for each type).
> >I was wondering how to subgraph from the whole network only nodes
> >with, say, green edges...
> I'd do it as follows:
> - create a copy of the graph
> - find the edges that do NOT have the given colour
> - remove these edges from the copy
> 
> In Python, you can do something like:
> 
> g2=g.copy()
> g2.delete_edges(g2.es.select(color_ne="red"))
> 
> In R, delete.edges returns a new graph object, so it does the copying  
> for you:
> 
> g2 <- delete.edges(g, E(g)[color != "red"])
> 
> -- 
> T.
> 
> 
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

-- 
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK




reply via email to

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