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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -