What is a loop in a graph?
A loop is an edge that connects a vertex to itself.
Formally: If an edge connects a vertex v to itself, it is a loop: (v, v).
Example
If a graph has a vertex A, and an edge goes from A → A, that is a loop, the vertex "refers" to itself.
Features
- A loop can occur in both directed and undirected graphs.
- It increases the degree of the vertex: in an undirected graph, a loop adds 2 to the degree, in a directed graph, 1 to the in-degree and 1 to the out-degree.
Interpretation
- In a social network, a user interacts with themselves.
- In automata, a state from which the system can remain in the same state.
Summary: a loop is an edge that starts and ends at the same vertex.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.