i wrote a Programm to calculate the connected edge with a specifial formel,and put the result into "Weight" Column of Edge.
to set the value,i used a for-code like
Code: Select all
for(Node m : graph.getNeighbors(n))
{...
edge.getEdgeData().getAttributes().setValue("Weight", result);}
because i will use those result later and need to avoid the NullPointerException. i wrote some method to fill all the Edge´s Weight
fisrt i put all the connected edges into a Arraylist then wrote a "hasedge" method
Code: Select all
public boolean hasEdge(Edge edge) {
for(Edge e: connectedEdges) {
if(edge.equals(e)) {
return true;
}
}
return false;
}
Code: Select all
public void fill(Graph graph){
for(Edge n :this.graph.getEdges().toArray()) {
if(!hasEdge(n)) {
n.getAttributes().setValue("Weight", Float.POSITIVE_INFINITY);
}
it seems that, the edge from .getedges() are all the edges,including the whole path.
any suggestion?