0

I am new here.. MY Question : i have used KKLayout for visualization a graph. The Graph is created in while-Loop (after each iteraion) after a new Calculation and every time the vertices is placed on random Locations/Postions. I want to fix them, so that they placed on same Position after each Loop-Iteration. How can i fix them ???? thanx

1 Answers1

0

By default, the force-directed layouts start with their vertices in random positions; this is why you're seeing this behavior.

There are a couple of different approaches that you can take to resolving this issue.

(1) Use the Layout.setInitializer() method to specify a consistent starting position for each vertex. This will ensure that KKLayout always does the same thing.

(2) If there is a specific layout result (set of positions) that you like, you can use StaticLayout initialized with those positions. PersistentLayoutImpl can be useful for serializing/restoring those positions if desired.

Joshua O'Madadhain
  • 2,704
  • 1
  • 14
  • 18
  • thank u so much 4 replying.. Actually i am using first Time JUNG2-Library in Java.. Can u give me one Example : How i can use Layout.setInitializier() and maybe staticLayout.. I want only : After each Claculation the Vertices's Postion staying same, so that man can concentrate on Calculation and not first on their Position and then their Calculation. Again Bundle of thanks.. – parilousfire Feb 17 '16 at 11:33
  • There's at least one sample in the JUNG distribution that uses StaticLayout; I suggest you take a look at those. – Joshua O'Madadhain Feb 17 '16 at 18:27
  • Can i fix the Location of Vertices, which is generated after first Iteration through KKlayout?? – parilousfire Feb 18 '16 at 17:50
  • You can at any time iterate over the positions stored in the `KKLayout` instance. `KKLayout` is an `IterativeLayout`, so each time `step()` is called the positions will advance. (step() is usually called automatically, but you can manage this manually if you like.) You can also create a StaticLayout based on a KKLayout instance; again, I recommend looking at the samples for example code. – Joshua O'Madadhain Feb 18 '16 at 18:29
  • thanx... i cannot call the Example Code :(:( .. i dont know, why :(.. i ll try it again .. thanks again .. – parilousfire Feb 18 '16 at 19:04
  • Code : Layout layout = new KKLayout(g); JFrame frame = new JFrame(" shortest Path"); layout.setSize(new Dimension(1000, 500)); In each Iteration : creation a new "layout'' with random Coordinates from Nodes after new Calculation. What i want : I want to fix the Coordinates from Nodes after first Creation of Layout, so that the fixed oordinates will be taken over from new "layout" in new Iteration. – parilousfire Feb 19 '16 at 11:09