algorithm - How to check if graph is connected using union find -


i need check if graph connected using union find algorithm. has one, can not use bfs or dfs, because need find minimal spanning tree using kruskal's algorithm if graph not connected, need return 0.

let's have this kruskal's algorithm using union find. there modification check if graph connected(we have 1 component)?

for example graph need return -1: enter image description here


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

javascript - Knockout pushing observable and computed data to an observable array -

c# - Update a combobox from a presenter (MVP) -