[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] How to create a vertex sequence using vertex label?
From: |
Gabor Csardi |
Subject: |
Re: [igraph] How to create a vertex sequence using vertex label? |
Date: |
Wed, 13 Jun 2007 10:05:37 +0200 |
User-agent: |
Mutt/1.5.12-2006-07-14 |
A bit better:
V(g)[ name=="casserole" ]
you can use the vertex attributes when indexing V(g). Example:
> library(igraph)
> el <- matrix( c("foo", "bar", "bar", "foobar"), nc=2, byrow=TRUE)
> g <- graph.edgelist(el)
> g
Vertices: 3
Edges: 2
Directed: TRUE
Edges:
[0] foo -> bar
[1] bar -> foobar
> V(g)[ name=="foo" ]
Vertex sequence:
[1] "foo"
> as.numeric(V(g)[ name=="foo" ])
[1] 0
> V(g)[ name %in% c("foo", "foobar") ]
Vertex sequence:
[1] "foo" "foobar"
G.
On Tue, Jun 12, 2007 at 11:34:19PM +0200, address@hidden wrote:
> I havn't the good solution for retreiving a vertex using it's label.
>
> Up to now, I use something like:
>
> V(g)[ which(V(g)$label == "casserole")-1 ]
>
> which is very inelegant... What is the right solution?
>
> Cheers,
> Sylvain
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
--
Csardi Gabor <address@hidden> MTA RMKI, ELTE TTK