I have a linklist of nodes which have a link list of edges. This method is trying to get the number of edges so the nodes will know how many edges it has. However, this doesn't really work and I am wondering how to fix it.
thank you in advance.
public int indegree() {
Node current = root;
int result=0;
while ( current != null ) {
System.out.print( current.name + ": " );
Edge currentEdge = current.firstEdge;
while ( currentEdge != null ) {
System.out.print( currentEdge.dest.name );
currentEdge = currentEdge.nextEdge;
result+=current.indegree;
}
System.out.println();
current = current.nextNode;
}
return result;
}