Re: [Jaslibrary-support] jas.graph.statistics
Brought to you by:
sonnessa
|
From: Sonnessa M. <son...@di...> - 2005-05-05 08:55:14
|
Dear Thomas,
the problem with your code is related to the deep connection
between NetworkStatComputer and the IRelationalAgent interface.
Some statistics require a node is a RelationalAgent to work.
Not only but in order to compute some statistics it is necessary
that the graph is a weighted and directed one.
So, a working version of your code can be something similar
to the following:
import jas.graph.*;
import jas.graph.statistics.*;
import org._3pq.jgrapht.graph.DirectedWeightedMultigraph;
public class TestConnectivity {
public static void main(String[] arguments) {
DirectedWeightedMultigraph g = new DirectedWeightedMultigraph();
IRelationalAgent[] agents = new IRelationalAgent[6];
agents[0] = new RelationalAgent(g);
agents[1] = new RelationalAgent(g);
agents[2] = new RelationalAgent(g);
agents[3] = new RelationalAgent(g);
agents[4] = new RelationalAgent(g);
agents[5] = new RelationalAgent(g);
agents[0].addRelation(agents[1], 1);
agents[0].addRelation(agents[2], 1);
agents[3].addRelation(agents[4], 1);
agents[1].addRelation(agents[5], 1);
agents[4].addRelation(agents[5], 1);
NetworkStatComputer stat = new NetworkStatComputer(g);
for(int i=1;i<25;i++){
try{
System.out.println(i + " : " + stat.getDoubleValue(i));
}
catch(Exception e) { System.out.println("Erreur pour "+ i +" "+ e);}
}
}
}
I hope it can be useful.
All the best,
Michele Sonnessa
Scrive Julien Thomas de Boer <jul...@ep...>:
> Hello,
> I ve got a problem with the function NetworkStatComputer.getDoubleValue.
> For some value_id, the error "java.lang.ClassCastException:
> java.lang.String" is returned. Actually, except for 1,14,16,18,19, i ve
> got this problem. Here is the code i typed ( i tested with some other
> graphs and i had still the same error) :
>
> public class test_connectivity {
> public static void main(String[] arguments) {
> ListenableDirectedGraph g = new ListenableDirectedGraph();
> g.addVertex("A");
> g.addVertex("B");
> g.addVertex("C");
> g.addVertex("D");
> g.addVertex("E");
> g.addVertex("F");
> g.addVertex("G");
> g.addEdge("A", "B");
> g.addEdge("A", "C");
> g.addEdge("D", "E");
> g.addEdge("B", "F");
> g.addEdge("F", "G");
> NetworkStatComputer stat = new NetworkStatComputer(g);
> for(int i=1;i<25;i++){
> try{
> System.out.println(i+":"+stat.getDoubleValue(i));
> }
> catch(Exception e) { System.out.println("Erreur pour"+i+" "+e);}
> }
> }
> }
>
> Thanks for your help.
>
>
|