Loading [MathJax]/jax/output/HTML-CSS/jax.js
ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Problems.BinaryTrees.SVG

Description

For a Tree which has been laid out with position (x,y) for every node, such as with layoutInorder, turns it into SVG so that the layout can be viewed graphically. Only trees with Char values are supported.

This is used to generate the graphical representation of binary trees for inclusion in the Haddock documentation generated for the layout problems. Doing it manually once was a painstaking and error-prone process; the thought of doing it two more times was too much. It could also be used to graphically explore alternative layout methods that are not included in one of the problems.

Synopsis

Documentation

toSVG :: Tree (Char, (Int, Int)) -> XML Source #

Renders a binary tree with Char values with annotated layout to SVG.

prettyXML :: XML -> Doc ann Source #

Pretty print XML, so we have prettier output instead of one very long line.

Supports a limited subset of XML sufficient to output SVG generated by toSVG.

writeSVG :: FilePath -> Tree (Char, (Int, Int)) -> IO () Source #

Writes the SVG for the binary tree to the given file.

data XML Source #

Represents XML content for the purposes of rendering Tree to SVG.

Instances

Instances details
Show XML Source # 
Instance details

Defined in Problems.BinaryTrees.SVG

Methods

showsPrec :: Int -> XML -> ShowS #

show :: XML -> String #

showList :: [XML] -> ShowS #