Reputation: 361
when I use "E(hu)[12]" for selecting a vertex I get the following output:
[12] A -- B
Now I need the names for these two vertices. How can I select the names/labels "A" and "B"? Thanks!
Upvotes: 3
Views: 1514
Reputation: 10825
You can use inc()
when indexing a vertex set, to get the incident vertices of an edge. This is probably the most readable:
# Some example data
library(igraph)
hu <- graph.ring(20)
V(hu)$name <- letters[1:20]
V(hu)[ inc(12) ]
# Vertex sequence:
# [1] "l" "m"
V(hu)[ inc(12) ]$name
# [1] "l" "m"
Upvotes: 3
Reputation: 361
I guess I could finally figure it out
V(g)[get.edges(hu, E(g)[12])[1]]
V(g)[get.edges(hu, E(g)[12])[2]]
Seems a bit too complex but it works...
Upvotes: 1