to_prufer {igraph} | R Documentation |
Convert a tree graph to its Prüfer sequence
Description
to_prufer()
converts a tree graph into its Prüfer sequence.
Usage
to_prufer(graph)
Arguments
graph |
The graph to convert to a Prüfer sequence |
Details
The Prüfer sequence of a tree graph with n labeled vertices is a sequence of n-2 numbers, constructed as follows. If the graph has more than two vertices, find a vertex with degree one, remove it from the tree and add the label of the vertex that it was connected to to the sequence. Repeat until there are only two vertices in the remaining graph.
Value
The Prüfer sequence of the graph, represented as a numeric vector of vertex IDs in the sequence.
See Also
make_from_prufer()
to construct a graph from its
Prüfer sequence
Other trees:
is_forest()
,
is_tree()
,
make_from_prufer()
,
sample_spanning_tree()
Examples
g <- make_tree(13, 3)
to_prufer(g)
[Package igraph version 2.0.3 Index]