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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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. 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.(2) Specify a consistent random seed when you create the layout. You’ll do this via the initializer; see
AbstractLayoutfor details.. (Not all layouts expose this capability, you might need to hack one to provide your own initializer.)(3) Use a layout that doesn’t have any random elements.