Indegree — Definition, Formula & Examples
Indegree is the number of edges that point into a given vertex in a directed graph. If three arrows lead to vertex , then the indegree of is 3.
For a directed graph and a vertex , the indegree of , denoted , is the cardinality of the set , i.e., the number of edges in whose head (terminal endpoint) is .
Key Formula
Where:
- = Indegree of vertex v — number of edges directed into v
- = Set of all vertices in the directed graph
- = Total number of directed edges in the graph
How It Works
To find the indegree of a vertex, look at every directed edge in the graph and count how many of them end at that vertex. An edge contributes 1 to the indegree of and 1 to the outdegree of . A useful identity ties indegree to the total edge count: the sum of all indegrees across every vertex equals the total number of edges, since each edge is counted exactly once as an incoming edge.
Worked Example
Problem: A directed graph has vertices and edges . Find the indegree of each vertex.
Count incoming edges to A: Only the edge ends at .
Count incoming edges to B: Edges , , and all end at .
Count incoming edges to C and D: Only ends at , and no edge ends at .
Verify with the sum formula: The sum of all indegrees should equal the number of edges.
Answer: The indegrees are: , , , .
Visualization
Why It Matters
Indegree is central to algorithms on directed graphs. PageRank weights a web page's importance partly by its indegree (how many other pages link to it). In topological sorting, vertices with indegree zero serve as the starting points of the algorithm (Kahn's algorithm).
Common Mistakes
Mistake: Confusing indegree with total degree by counting both incoming and outgoing edges.
Correction: Indegree counts only edges directed into the vertex. Outgoing edges contribute to the outdegree, not the indegree. In a directed graph, the total degree of a vertex is the sum of its indegree and outdegree.
