开发者

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜