Statistics:Posted by Crispy — 13 Mar 2018 00:25
CODE:
package nodesizegephi;import java.util.ArrayList;import java.util.List;public class NodeSizeGephi{ private static float sizeMinimum, sizeMaximum; private static void setDefaults() { sizeMaximum = 100f; sizeMinimum = 4f; } public static void main(String[] args) { setDefaults(); //... Inject my two nodes List<Node> nodes = new ArrayList<>(); nodes.add(new Node(20.0f)); nodes.add(new Node(21.0f)); float sizeMin = Float.POSITIVE_INFINITY; float sizeMax = Float.NEGATIVE_INFINITY; float sizeRatio = 0f; //Measure for( Node node : nodes ) { sizeMin = Math.min(node.getSize(), sizeMin); sizeMax = Math.max(node.getSize(), sizeMax); } if (sizeMin != 0 && sizeMax != 0) { if (sizeMin == sizeMax) { sizeRatio = sizeMinimum / sizeMin; } else { sizeRatio = (sizeMaximum - sizeMinimum) / (sizeMax - sizeMin); } //Scale node size for( Node node : nodes ) { float size = (node.getSize() - sizeMin) * sizeRatio + sizeMinimum; node.setSize(size); } } nodes.forEach((node)->System.out.println("Node size: " +node.getSize())); }}class Node{ private float size; public Node(float size) { this.size = size; } public float getSize() { return size; } public void setSize(float size) { this.size = size; }}
Running this I get returned:Statistics:Posted by Crispy — 12 Mar 2018 23:48
Statistics:Posted by eduramiba — 12 Mar 2018 17:31
CODE:
<?xml version='1.0' encoding='UTF-8'?><gexf xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http://www.gexf.net/1.2draft/viz" version="1.2"> <meta lastmodifieddate="2018-03-12"> <creator>Tester</creator> <description>Node size test</description> </meta> <graph defaultedgetype="undirected" idtype="string" mode="static"> <nodes count="2"> <node id="3" label="NodeSize:21.0"> <viz:color r="255" g="0" b="0"/> <viz:size value="21.0"/> </node> <node id="4" label="NodeSize:20.0"> <viz:color r="204" g="204" b="255"/> <viz:size value="20.0"/> </node> </nodes> <edges count="0"> </edges> </graph></gexf>
They generate vastly different size nodes as shown below. The smaller node (20.0) is just visible on the top left of the 'z'. The larger (red) node is significantly larger. What is the size ratio algorithm? I see someone asked a similar question nearly two years ago but without reply.Statistics:Posted by Crispy — 12 Mar 2018 15:41