Background
An undirected graph is a mathematical representation of a set of objects in which some pairs of the objects are connected by links. The objects are represented by vertices (or nodes) and the links are represented by edges.
In an undirected graph, the edges have no direction, meaning they can be traversed in both directions. It means if there is an edge between vertex A and B, then it is also true that there is an edge between vertex B and A.
A simple example of an undirected graph would be a group of cities and the roads connecting them. Each city would be represented by a vertex, and the roads connecting the cities would be represented by edges. It would not matter whether you are travelling from city A to city B or from city B to ...