to_prufer
converts a tree graph into its Prufer sequence.
to_prufer(graph)
The graph to convert to a Prufer sequence
The Prufer sequence of the graph, represented as a numeric vector of vertex IDs in the sequence.
The Prufer 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.
make_from_prufer
to construct a graph from its
Prufer sequence
# NOT RUN {
g <- make_tree(13, 3)
to_prufer(g)
# }
Run the code above in your browser using DataLab