The implementation for my graph is the following hash table:
public class DiGraphHash{
private int numNodos, numArcos;
private TheList<Nodo> nodos[];
private TheList<Arco> arcos[];
private TheList<Arco> preds[];
}
where TheList, is a list I made myself.
For Dijkstra's algorithm I need to map The cost of each node and the path to reach that node. I have the following two arrays:
int[] cost = new cost[num_nodes];
Nodo[] path = new Nodo[num_nodes];
Another important detail, is that my nodes are going to be the letters A, B, C, D.
So when I map my nodes, for example lets say I have to assign the cost the the Node A, how do I find the position in the array?
I was thinking of using hashcode % array.length but I am not sure if I will get collisions (take into consideration that it will be only 1 char letters)
I am not asking about the code, and need the idea.