Content-Length: 268280 | pFad | http://github.com/noamz/diagrams/blob/master/README.md

2F diagrams/README.md at master · noamz/diagrams · GitHub
Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 2.08 KB

README.md

File metadata and controls

59 lines (43 loc) · 2.08 KB

fun with diagrams

Various bits of visualization code based on the diagrams library.

RemyVis

RemyVis.hs: generates an animation of Remy's algorithm for uniformly generating random binary trees:

Remy's algorithm animation

Luka

Luka.hs: some routines for visualizing generalized Łukasiewicz paths:

*Luka> walkSVG' 1 "U2DU1DDU1DD"

U2DU1DDU1DD

*Luka> walkSVG' 1 "U1DU2DU1DDD"

U1DU2DU1DDD

*Luka> walkSVG' 0 "UUUD2UUD2UUUD2D2"

UUUD2UUD2UUUD2D2

LukaTree

LukaTree.hs: visualizing trees as paths. (This uses routines for visualizing operadic trees from the LinLam library.)

Each tree is encoded as a Łukasiewicz path in four different ways, respectively via its preorder left-to-right, preorder right-to-left, postorder left-to-right, and postorder right-to-left traversals.

> t = bin (bin (bin zer (bin zer zer)) zer) (bin (bin (bin zer zer) zer) (bin zer zer))
> renderPretty "binwalk.svg" (mkWidth 2048) (treeWalksDiagram t)

binwalk

> t = ter (bin zer zer) (ter zer zer (bin zer zer)) zer
> renderPretty "terwalk.svg" (mkWidth 1024) (treeWalksDiagram t)

terwalk

> renderPretty "allbin3walk.svg" (mkWidth 1024) (vsep 1 [treeWalksDiagram t | t <- kTree 2 3])

allbin3walk

We can also consider the reverse translation from walks to trees. Here we interpret a walk not touching the x-axis as a tree with free leaves, respectively via its preorder left-to-right and preorder right-to-left traversals:

> w = readWalk "U1U1U1D1U1D1D1U1U1D1"
> renderPretty "walk2tree.svg" (mkWidth 1024) (hsep 1 [gridWalk 1 w # centerXY, treeDiagram (unpreLR w) # centerXY, treeDiagram (unpreRL w) # centerXY] # pad 1.1)

allbin3walk









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/noamz/diagrams/blob/master/README.md

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy