Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Degree of Vertex of a Graph
The degree of a vertex V is the number of edges incident with (connected to) that vertex.
Notation − deg(V)
In a simple graph with n vertices, the maximum degree of any vertex is −
deg(v) ≤ n - 1, for all v in G
A vertex can form an edge with all other vertices except itself. So the degree of a vertex will be at most the number of vertices minus 1. If there is a loop at any vertex, then it is not a simple graph.
Degree of a vertex can be considered under two cases −
- Undirected Graph − Degree is the total number of edges at a vertex.
- Directed Graph − Each vertex has an indegree (incoming edges) and an outdegree (outgoing edges).
Degree of Vertex in an Undirected Graph
An undirected graph has no directed edges. The degree of a vertex is simply the count of edges connected to it.
Example 1
Take a look at the following graph −
In the above undirected graph −
- deg(a) = 2, as there are 2 edges meeting at vertex 'a'.
- deg(b) = 3, as there are 3 edges meeting at vertex 'b'.
- deg(c) = 1, as there is 1 edge at vertex 'c'. So 'c' is a pendent vertex.
- deg(d) = 2, as there are 2 edges meeting at vertex 'd'.
- deg(e) = 0, as there are 0 edges at vertex 'e'. So 'e' is an isolated vertex.
Example 2
Take a look at the following graph −
In the above graph, deg(a) = 2, deg(b) = 2, deg(c) = 2, deg(d) = 2, and deg(e) = 0. The vertex 'e' is an isolated vertex. The graph has no pendent vertices.
Degree of Vertex in a Directed Graph
In a directed graph, each vertex has an indegree and an outdegree.
Indegree − The number of edges coming into the vertex. Notation: deg−(V).
Outdegree − The number of edges going out from the vertex. Notation: deg+(V).
Example 1
Take a look at the following directed graph. Vertex 'a' has two edges 'ad' and 'ab' going outwards (outdegree = 2), and one edge 'ga' coming inwards (indegree = 1) −
The indegree and outdegree of all vertices are −
| Vertex | Indegree | Outdegree |
|---|---|---|
| a | 1 | 2 |
| b | 2 | 0 |
| c | 2 | 1 |
| d | 1 | 1 |
| e | 1 | 1 |
| f | 1 | 1 |
| g | 0 | 2 |
Example 2
Take a look at the following directed graph −
The indegree and outdegree of all vertices are −
| Vertex | Indegree | Outdegree |
|---|---|---|
| a | 1 | 1 |
| b | 0 | 2 |
| c | 2 | 0 |
| d | 1 | 1 |
| e | 1 | 1 |
Conclusion
The degree of a vertex counts the number of edges connected to it. In undirected graphs, vertices with degree 0 are isolated and those with degree 1 are pendent. In directed graphs, the degree is split into indegree (incoming edges) and outdegree (outgoing edges).
