Safe Haskell | None |
---|---|
Language | Haskell2010 |
Prufer sequences
Functions to convert trees to Prufer sequences and vice versa
Sources:
- https://en.wikipedia.org/wiki/Pr%C3%BCfer_sequence
- Xiaodong Wang, Lei Wang, Yingjie Wu, "An Optimal Algorithm for Prufer Codes", 2009 https://www.scirp.org/pdf/JSEA20090200006_93737200.pdf
Documentation
graphToSeq :: Graph -> [Vertex] Source #
Convert a bidirected Graph to a Prufer sequence. The graph must be a connected tree or empty. O(n).
treeToSeq :: Bounds -> Tree Vertex -> [Vertex] Source #
Convert a Tree to a Prufer sequence. The tree must be rooted at r. O(n).