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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -