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 -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -