![]() |
VOOZH | about |
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.
3