【发布时间】:2016-10-29 21:00:03
【问题描述】:
我需要创建两个二叉搜索树图,显示 radix-2 和 radix
为此,我决定使用 python igraph 库并发现了 Fruchterman-Reingold 力导向函数,例如:
from igraph import *;
pl=Plot();
g = Graph.Tree(16, 2);
layout = g.layout("rt", 1); # Reingold-Tilford tree layout, useful for (almost) tree-like graphs
pl.add(g, layout=layout);
pl._windows_hacks=True;
pl.show();
不幸的是,这会生成一个分支不是二进制的树,即我在根节点之后得到三个节点。我还需要一个平衡树,这个函数似乎没有提供(树枝不平衡):
我在 igraph 库中使用了 Bipartite 类方法,但我不确定我是否走在正确的道路上。
如果在 igraph 和树可视化方面更有经验的人可以帮我解决这个问题,我会很高兴。
【问题讨论】:
标签: python algorithm binary-search-tree