Im trying to add edge weights to a 2-d array. im looped through the graph edges, then looped through the nodes and comparing the 2 to find the index of the head node and the tail node, then trying to add that to the array. But its telling me my variables arent initialized. Any ideas?
int head;
int tail;
for (int i = 0; i < g.edgeList.size(); i++) {
for (int j = 0; j < g.nodeList.size(); j++) {
if (g.nodeList.get(j) == g.edgeList.get(i).head) {
head = g.nodeList.indexOf(j);
}
if (g.nodeList.get(j) == g.edgeList.get(i).tail) {
tail = g.nodeList.indexOf(j);
}
W[head][tail] = Integer.parseInt(g.edgeList.get(i).label);
}
}