java - Get set of edges -
i seem have problem using/understanding sets. in jgrapht there function edgeset(). store edges in array, did this:
defaultweightededge edgescontained[]= (defaultweightededge[]) graph.edgeset().toarray(); //compiler returns line 1 error ( int i=0; i<=numberofedges; i++) { setrandomweight(edgescontained[i], randomweight()); } but output is
exception in thread "main" java.lang.classcastexception: [ljava.lang.object; cannot cast [lorg.jgrapht.graph.defaultweightededge;
why , how should properly?
graph.edgeset().toarray() return object[], cannot cast defaultweightededge[]. instead use graph.edgeset().toarray(new defaultweightededge[0]).
Comments
Post a Comment