We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › help with simple FDL network problem
Page Index Toggle Pages: 1
help with simple FDL network problem (Read 456 times)
help with simple FDL network problem
Sep 11th, 2008, 5:37pm
 
hi
i am trying to teach myself processing(and programming) and I am getting hung up on something - I'm trying to use values from a TSV file and feed them into a force directed layout graph I found here:

http://www.cricketschirping.com/weblog/?p=545

I have been attacking it from various angles but I can't seem to overcome the impasse. I think that I'm not too far off...here's the buildgraph function[I find that if I comment out the edges portion the app compiles I just get nothing on screen which makes me think that the problem is somewhere in that part...]:

Graph buildRandomGraph() {
 Graph g;
 int nNodes = rowCountAVT-1;
 int nEdges = 2;
 g = new Graph();

 for (int row=1; row<rowCountAVT; row++) {
    //String diet = animalValuesTable.getString(row,15);
    float weight = animalValuesTable.getFloat(row,1);
    String common = animalValuesTable.getString(row,0);
   
    ForcedNode n = new ForcedNode(new Vector3D(W/4 + random(W/2), H/4 + random(H/2), 0));
    n.setLabel(common+"");
    n.setMass(weight);
    g.addNode(n);
  }
 
 for (int i=0; i<nEdges; i++) {
   Node a = (Node)g.getNodes().get((int)random(g.getNodes().size()));
   Node b = (Node)g.getNodes().get((int)random(g.getNodes().size()));
   if (a != b && !(g.isConnected(a,b))) {
     SpringEdge e = new SpringEdge(a, b);
     e.setNaturalLength(random(10));
     g.addEdge(e);
   }
 }
 
 return g;
}

and for the whole sh-bang go here:
http://friedmanstudios.ca/chimera_obscura/processing/GraphLayout_animals/applet/
Re: help with simple FDL network problem
Reply #1 - Sep 12th, 2008, 2:34pm
 
i'm seeing "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0" on the line that does the getNodes().. i would suspect that rowCountAVT might be set properly, so the for() loop is not running at all.
Re: help with simple FDL network problem
Reply #2 - Sep 12th, 2008, 7:19pm
 
i think i solved that...now I am getting edges...but no nodes?

here's the latest version:


http://friedmanstudios.ca/chimera_obscura/processing/GraphLayout_animals2/applet/

I have culled most of the edges (removed 2200) just to rule out the possibility that the sheer number of edges might cause performance issues:

weightedEdgesTable = new Table("weightexperiment-02.txt");
rowCountWET = weightedEdgesTable.getRowCount();
 
for (int row=0; row<rowCountWET-2200; row++) {
Page Index Toggle Pages: 1