如何使用 JUNG 绘制树层次结构?
我是 JUNG 的新手。我尝试使用 TreeLayout 绘制树图,但树永远不会像真正的树一样出现。每次树看起来都不一样。我怎样才能让这棵树看起来像一棵普通的树,根在顶部,根在顶部?从它下降的其余节点?
I'm new to JUNG. I tried to draw a graph of a tree using the TreeLayout but the tree never comes out like a real tree. Every time the tree looks different. How can I make the tree look like a normal tree with the root on top & the rest of the nodes descending from it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将顶点添加到图形后,您必须初始化
TreeLayout
,我尝试过,它对我有用。你必须做如下的事情:(请注意,这是我的 1 年前的代码,你可能会发现它有点过时)
GraphVertex
是表示顶点的类在图中,GraphEdge
表示图中的边。You have to Initialize the
TreeLayout
after adding the Vertexes to the graph, I tried that and it worked for me.You have to do something like the following: (please note that this is a 1 year old code that i had, you might find it to be a little out dated)
GraphVertex
Is the class which represents a vertex in the graph,GraphEdge
represents the edges in your graph.