Home Wiki Blog Forum GEXF.net

Gephi forums

Community support

making distance proportional to edge weight + avoid overlap

Automated tasks on server

making distance proportional to edge weight + avoid overlap

Postby noarappaport » 03 Mar 2013 10:00

I am using the toolkit for building PDF network files from GFEX input files. I would like two things:
1. That the weight will be proportional to the distance. I understand this can be done using the force atlas layout algorithm.
2. I'd like the labels to not overlap.

The question is how to implement this...
Currently I am using the following code for layout:
Code: Select all

   //Run YifanHuLayout for 100 passes - The layout always takes the current visible view
            YifanHuLayout layout = new YifanHuLayout(null, new StepDisplacement(1f));
            for (int i = 0; i < 100 && layout.canAlgo(); i++) {
            ForceAtlas2 fa2Layout = new ForceAtlas2(new ForceAtlas2Builder());

            for (int i = 0; i < 100 && fa2Layout.canAlgo(); i++)
             Node[] nodes = graphModel.getGraph().getNodes().toArray();
                for (int i = 0; i < nodes.length; i++)
                   //Get the TextDataImpl object
                   TextDataImpl td=(TextDataImpl) nodes[i].getNodeData().getTextData();
                   String labelText=nodes[i].getNodeData().getLabel();
                   //Could perhaps used getFontMetrics here to be more accurate but
                   // this heuristic seems to work for me:
                   Rectangle2D bounds=new Rectangle(labelText.length()*100,100);
                   //Use reflection to set the protected Bounds data to non-zero sizes.
                   Field protectedLineField = TextDataImpl.class.getDeclaredField("line");
                   TextLine line = (TextLine) protectedLineField.get(td);

               LabelAdjust laLayout = new LabelAdjust(new LabelAdjustBuilder());
               for (int i = 0; i < 50000 && laLayout.canAlgo(); i++)

Posts: 13
Joined: 05 Nov 2012 15:52

Return to Toolkit

Who is online

Users browsing this forum: No registered users and 1 guest