|
From: | Tamas Nepusz |
Subject: | Re: [igraph] how to translate from R to Python... |
Date: | Mon, 22 Sep 2008 15:05:08 +0100 |
I am a newbie to Python... can you give me an hint on how to translate this R code:It's a little bit complicated since adj() is an R-specific extension to igraph. It takes an edge sequence and returns a boolean vector that is true for vertices that are adjacent to at least one of the edges. Something similar in Python can be implemented as a separate method:g2 <- subgraph(g, V(g) [ adj(E(g) [ color=="green" ]) ])
def adj(es): result = set() for e in es: result.add(*e.tuple) return list(result) g2 = g.subgraph(adj(g.es.select(color="green"))) -- Tamas
[Prev in Thread] | Current Thread | [Next in Thread] |