VOOZH about

URL: https://www.geeksforgeeks.org/dsa/find-degree-particular-vertex-graph/

⇱ Find the Degree of a Particular vertex in a Graph - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Find the Degree of a Particular vertex in a Graph

Last Updated : 1 Aug, 2022

Given a graph G(V,E) as an adjacency matrix representation and a vertex, find the degree of the vertex v in the graph.

Examples : 

0-----1
|\ |
| \ |
| \|
2-----3
Input : ver = 0
Output : 3

Input : ver = 1
Output : 2

Algorithm:

1. Create the graphs adjacency matrix from src to des 
2. For the given vertex then check if 
 a path from this vertices to other exists then
 increment the degree.
3. Return degree 

Below is the implementation of the approach.


Output
3
Comment
Article Tags: