简体   繁体   English

JUNG:在相同位置加载图节点

[英]JUNG: Loading Graph nodes in same location

I'm new to JUNG. 我是荣格的新手。 I have created nodes in a Graph. 我在图中创建了节点。 Now when ever I run the program I get nodes with different location. 现在,每当我运行该程序时,我都会获得具有不同位置的节点。 How can I load the nodes I created in same location everytime? 每次如何在相同位置加载我创建的节点?

There are a few ways of going about this. 有几种解决方法。

(1) Get the nodes where you want them, and then save the positions for later use. (1)获取所需的节点,然后保存位置以备后用。 For example, you can use PersistentLayoutImpl (if you want to serialize the entire graph), or store some kind of map from vertex identifier to layout position. 例如,可以使用PersistentLayoutImpl (如果要序列化整个图形),或存储从顶点标识符到布局位置的某种映射。

(2) Specify a consistent random seed when you create the layout. (2)创建布局时,请指定一致的随机种子。 You'll do this via the initializer; 您将通过初始化程序来完成; see AbstractLayout for details.. (Not all layouts expose this capability, you might need to hack one to provide your own initializer.) 有关详细信息,请参见AbstractLayout 。(并非所有布局都具有此功能,您可能需要修改一下才能提供自己的初始化程序。)

(3) Use a layout that doesn't have any random elements. (3)使用没有任何随机元素的布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM