Martin Ueding
Martin Ueding

Reputation: 8719

Convert nested list into tree picture

I have a JSON/Python nested list which represents a tree, each item being a node, if the node is a list, it is a subtree.

Any easy way to create some pleasing graphics out of that?

[[1, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]], [2, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]], [3, [[4, [[7], [8], [9]]], [5, [[7], [8], [9]]], [6, [[7], [8], [9]]]]]]

This is a neater layout of the JSON itself, which does not help me too much.

Upvotes: 0

Views: 717

Answers (1)

Kurt Stutsman
Kurt Stutsman

Reputation: 4034

You could look into GraphViz for making basic graph images using its simple dot notation. Then in python you could make a really simple recursive function that generates the dot file and builds the graph.

Upvotes: 1

Related Questions