Reputation: 33
let's say we have a HashMap with for a graph with node and adjacency list
HashMap[node:Long,compId:Long, neighbours:Set[Long])]
what is the best way to update all the nodes with the minimum compId(connected component id) and what is the best data structure that can be used when the size of the data is large?
Upvotes: 0
Views: 112
Reputation: 535
just use disjoint set data struture, in general case, the amortized complexity would be O(1), very fast!!
Upvotes: 1