GraphStream Users

Archives de la liste Aide


Re: Problem with retrieving Node Position


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: "graphstream-users AT litislab.fr" <graphstream-users AT litislab.fr>, Barbaros Özdemir <barbaros.oezdemir AT gmail.com>
  • Subject: Re: Problem with retrieving Node Position
  • Date: Tue, 11 Aug 2015 22:55:01 +0200

Hi,

In your example, layout computation is done after you try to get the coordinates. But wherever you put the layout activation code, this will be done inside the viewer thread, so you will have to get the coordinates inside this thread or to create a pipe between the viewer and your graph.
There is an easier path : using the `computeLayout(Graph)` method of Toolkit (here).

Hope it helps.
Cheers.

2015-08-11 16:53 GMT+02:00 Barbaros Özdemir <barbaros.oezdemir AT gmail.com>:
Hi @all,

i tried to retrieve node positions just as suggested on the tutorial page (http://graphstream-project.org/doc/Tutorials/Graph-Visualisation_1.0/#viewers) in chapter 2 under "Retrieving nodes coordinates of the automatic layout". 

I do however get for each node the position "0.0 0.0 0.0", which does not make any sense as the drawn graph looks different. 

I appreciate any feedback/comment on what i am doing wrong. 

Thanks in advance. 

Best regards,
Barbaros Özdemir

PS: Here the code i have executed;

Import org.graphstream.graph *.
Import org.graphstream.graph.implementations *.
Import org.graphstream.ui.view.Viewer;

import static org.graphstream.algorithm.Toolkit *.
 
public class Tutorial1 {
        public static void main (String args []) {
         Graph graph = new Graph Single ("Tutorial 1");
        
         graph.addNode ("A");
         graph.addNode ("B");
         graph.addNode ("C");
         graph.addNode ("D");
         graph.addEdge ("AB", "A", "B");
         graph.addEdge ("AC", "A", "C");
         graph.addEdge ("AD", "A", "D");
         graph.addEdge ("BD", "B", "D");
         graph.addEdge ("BC", "B", "C");
         graph.addEdge ("DC", "D", "C");
                 
         for (Node n: graph) {
         String nodeId = n.getId ();
         Node node = graph.getNode (nodeId);
         Double pos [] = nodePosition (node);
         System.out.print (n.getId () + "");
         for (int i = 0; i <pos.length; i ++) {
         System.out.print (pos [i] + "");
         }
         System.out.println ("");
         }
        
         Viewer viewer = graph.display ();
         viewer.enableAutoLayout ();
        }
}

PPS: And here the output (the graph is in attachment): 

A: 0.0 0.0 0.0 
B: 0.0 0.0 0.0 
C: 0.0 0.0 0.0 
D: 0.0 0.0 0.0 




--
Guilhelm Savin
PhD of Computer Science



Archives gérées par MHonArc 2.6.16.

Top of page