Return root, end, or branchpoints of an igraph object
graph.nodes(
x,
type = c("root", "end", "branch"),
original.ids = "name",
exclude.isolated = TRUE
)
An ngraph
or raw igraph
object
one of root, end (which includes root) or branch
Use named attribute to return original vertex ids (when available). Set to FALSE when this is not desired.
Do not count isolated vertices as root/end points (default)
This function underlies rootpoints.igraph
methods and
friends. It is conceived of as slightly lower level and end users would
normally use the rootpoints
methods.
graph.nodes
should work for any igraph
object
(including ngraph
objects, which inherit from igraph
).
However the graph must be directed in order to return a root point
ng=as.ngraph(Cell07PNs[[1]])
# set some arbitrary vertex identifiers
igraph::vertex_attr(ng, 'name') <-sample(500, nvertices(ng))
# return those identifiers
graph.nodes(ng, type = 'end')
#> [1] 440 270 349 424 390 380 453 215 271 195 50 11 65 80 316 214 319 138
# ... or raw vertex indices
graph.nodes(ng,type = 'end', original.ids = FALSE)
#> [1] 1 42 59 62 80 85 96 100 102 112 117 121 134 148 154 165 172 180