0

I am coding an implementation of Prim's algorithm for deriving a Minimum Spanning Tree. My Graph is a Map<String, ArrayList> in which they keys correspond to the state name and the values are the edges which hold pointers to both links.

Prim's Algorithm says I should start with a Tree only containing the starting node then loop until my tree is equivalent to my graph. How can I determine equivalence of a TreeMap<String, ArrayList> and Map<String, ArrayList>?

Brian
  • 7,098
  • 15
  • 56
  • 73

1 Answers1

0

If by equivalence you mean key, value pairs in both maps are exactly same then you can simply use Map.equals() method which checks if entry set is same for both maps.

Ashwinee K Jha
  • 9,187
  • 2
  • 25
  • 19