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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if incoming edges in a vertex of directed graph is equal to vertex itself or not
- Check if vertex X lies in subgraph of vertex Y for the given Graph
- Check if every vertex triplet in graph contains two vertices connected to third vertex
- Maximum number of edges that N-vertex graph can have such that graph is Triangle free | Mantel's Theorem
- Find if a degree sequence can form a simple graph | Havel-Hakimi Algorithm
- Degree of a Cycle Graph
- Nodes with prime degree in an undirected Graph
- Difference Between sum of degrees of odd and even degree nodes in an Undirected Graph
- Find a Mother vertex in a Graph using Bit Masking
- Find dependencies of each Vertex in a Directed Graph
- Find a Mother Vertex in a Graph
- Finding minimum vertex cover size of a graph using binary search
- Topological Sort of a graph using departure time of vertex
- k'th heaviest adjacent node in a graph where each vertex has weight
- All vertex pairs connected with exactly k edges in a graph
- Add and Remove vertex in Adjacency Matrix representation of Graph
- Add and Remove vertex in Adjacency List representation of Graph
- Degree Centrality (Centrality Measure)
- Spanning Tree With Maximum Degree (Using Kruskal's Algorithm)
- Print the degree of every node from the given Prufer sequence
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.