What is an undirected graph?
An undirected graph is a graph in which edges have no direction.
Formally: A graph G = (V, E), where each edge is an unordered pair of vertices {u, v}. This means the connection between u and v is mutual: u ↔ v.
Main idea
If vertices are connected, movement is possible in both directions. That is, the edge {A, B} means a connection both as A → B and B → A at the same time.
Example
If there are vertices A, B, C, and edges:
- A-B,
- B-C, then you can go from A to C and back, through B.
Typical applications
- Friendship on social networks (both added each other).
- Roads between cities, if traffic is two-way.
- Interaction networks, where the connection is mutual.
Summary: in an undirected graph, all connections are two-way, direction does not matter.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.