Practice 30 Best C Programming Questions on Graph


Q1. Write a program to represent an undirected graph using an adjacency matrix.

Q2. Represent an undirected graph using an adjacency list.

Q3. Write a program to perform Depth-First Search (DFS) on a graph represented as an adjacency matrix.

Q4. Write a program to perform Breadth-First Search (BFS) on a graph represented as an adjacency matrix.

Q5. Write a program to count the number of nodes in an undirected graph.

Q6. Write a program to count the number of edges in an undirected graph represented by an adjacency matrix.

Q7. Write a program to detect self-loops in a graph represented by an adjacency matrix.

Q8. Write a program to find the degree of each vertex in an undirected graph.

Q9. Write a program to check if there is an edge between two given vertices in an adjacency matrix.

Q10. Count the number of connected components in an undirected graph using DFS.

Q11. Write a program to check if a graph is bipartite using BFS.

Q12. Implement Prim's algorithm to find the MST of a weighted graph.

Q13. Write a program to find the shortest path from a source node in an unweighted graph using BFS.

Q14. Write a program to find all paths between two nodes in a graph using Depth-First Search (DFS).

Q15. Implement Dijkstra’s algorithm to find the shortest path from a source node in a weighted graph.

Q16. Write a program to detect if there is a cycle in an undirected graph using DFS.

Q17. Write a program to count the number of connected components in an undirected graph.

Q18. Write a program to perform topological sorting on a directed acyclic graph using DFS.

Q19. Write a program to transpose a given directed graph (i.e., reverse all edges).

Q20. Write a program to find articulation points (cut vertices) in an undirected graph.

Q21. Write a program to find all bridges (cut edges) in an undirected graph.

Q22. Write a program to find the degree of each node in an undirected graph.

Q23. Write a program to check if a Hamiltonian Path exists in a given graph.

Q24. Write a program to determine if a graph contains an Eulerian path.

Q25. Write a program to calculate the diameter of a graph (longest shortest path).

Q26. Write a program to detect all leaf nodes in a tree.

Q27. Write a program to count the number of edges in an undirected graph.

Q28. Implement the Floyd-Warshall algorithm to find shortest paths between all pairs of vertices in a weighted graph.

Q29. Write a program to detect cycles in a directed graph using Depth First Search (DFS).

Q30. Write a program to find the shortest path from a source vertex to all other vertices in a weighted graph using Dijkstra's Algorithm.

Social Share

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!

Programming Languages