layoutjungjung2

Fixing Vertices in Layout (KKLayout) JUNG/JUNG2


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


Solution

  • 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.