My project is to implement minimum spanning tree using java. I aim to use Prim's algorithm to do the task.
The definition of the graph is G = (V, E) where V is the set of pins, E is the set of possible interconnections between pairs of pins, and for each edge (u,v) in E we have a weigh w(u,v) specifying the cost to connect u and v.
My idea is to use two hashmaps. First would have pin as a key and a list of neighbours as value. The second hashmap would take list of edge (u,v) as a key and the value would be its weight.
What do you think is the best way to store the graph?