|
Algorithms_in_C++
1.0.0
Set of algorithms implemented in C++.
|
Graph Connected Components (Connected Components) More...
#include <algorithm>#include <iostream>#include <vector>Classes | |
| class | graph |
Functions | |
| int | main () |
Graph Connected Components (Connected Components)
A graph is a collection of nodes also called vertices and these vertices are connected by edges. A connected component in a graph refers to a set of vertices which are reachable form one another.
Example - Here is graph with 3 connected components
3 9 6 8
/ \ / / \ / \
2---4 2 7 3 7first second third component component component
| int main | ( | ) |
Main function
creating a graph with 4 vertex
Adding edges between vertices
printing the connected components