Given a graph G(V,E) as an adjacency matrix representation and a vertex, find the degree of the vertex v in the graph.
0-----1 |\ | | \ | | \| 2-----3 Input : ver = 0 Output : 3 Input : ver = 1 Output : 2
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.
// This code is contributed by rishabhdeepsingh98
- Find a Mother Vertex in a Graph
- All vertex pairs connected with exactly k edges in a graph
- Degree of a Cycle Graph
- Topological Sort of a graph using departure time of vertex
- k'th heaviest adjacent node in a graph where each vertex has weight
- Finding minimum vertex cover size of a graph using binary search
- Find k-cores of an undirected graph
- Find if there is a path between two vertices in a directed graph
- Find if an undirected graph contains an independent set of a given size
- Finding the path from one vertex to rest using BFS
- Program to find Circuit Rank of an Undirected Graph
- Find minimum weight cycle in an undirected graph
- Program to find the diameter, cycles and edges of a Wheel Graph
- Disjoint Set (Or Union-Find) | Set 1 (Detect Cycle in an Undirected Graph)
- Program to find total number of edges in a Complete Graph
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : rds_98