Please consider the following
library(igraph)
id <- c("1","2","A","B")
name <- c("02 653245","03 4542342","Peter","Mary")
category <- c("digit","digit","char","char")
from <- c("1","1","2","A","A","B")
to <- c("2","A","A","B","1","2")
nodes <- cbind(id,name,category)
edges <- cbind(from,to)
g <- graph.data.frame(edges, directed=TRUE, vertices=nodes)
Now I want to access a specific vertex of the graph using the ids I used to create the graph from the data frame id <- c("1","2","A","B")
.
Let's say I want to access the third vertex - originally identified with "A". Is there any way to access the vertex with something like
V(g)$id == "A"
And is there anyway to obtain the id
from name
? That is, if I run
which(V(g)$name == "Peter")
I get 3
. How to get A
instead?