Given a graph fg, my example:
library("igraph")
fg <- feature.graph <- graph.empty()
fg <- fg + vertices("root", "ho", "ha", value=c(1,2,3)) +
edges(c("root", "ho", "root", "ha"), label=c("en", "an"), prob=c(0.2,0.8))
I extract an edge of interest:
> edge.of.interest <- E(fg)[from("root")][[1]]
> edge.of.interest
Edge sequence:
e
e [1] root -> ho
To now get the source or the target of this edge I can do:
> get.edge(fg, edge.of.interest)
[1] 1 2
> get.edge(fg, edge.of.interest)[1]
[1] 1
> get.edge(fg, edge.of.interest)[2]
[1] 2
I would have expected a function source and target with this effect:
> target(edge.of.interest)
2
I have been unable to find this or equivalent functions. Is the method through get.edge the best there is?
I know it is an old question but it looks like I have an answer from the top of my head. Do you mean tail_of
and head_of
?
> head_of(fg, edge.of.interest)$value
[1] 1
> tail_of(fg, edge.of.interest)$value
[1] 2
Also, ends
function may be useful here if both ends are needed at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With