Spaces:
Sleeping
Sleeping
You are given a simple undirected graph consisting of n vertices. The graph doesn't contain self-loops, there is at most one edge between each pair of vertices. Your task is simple: make the graph connected.You can do the following operation any number of times (possibly zero): Choose a vertex u arbitrarily. For each vertex v satisfying v≠u in the graph individually, if v is adjacent to u, remove the edge between u and v, otherwise add an edge between u and v. Find the minimum number of operations required to make the graph connected. Also, find any sequence of operations with the minimum length that makes the graph connected. |