Given a graph G, the task is to check if it represents a Ring Topology.
A Ring Topology is the one shown in the image below:
Input : Graph = Output : YES Input : Graph = Output : NO
A graph of V vertices represents a Ring topology if it satisfies the following three conditions:
- Number of vertices >= 3.
- All vertices should have degree 2.
- No of edges = No of Vertices.
The idea is to traverse the graph and check if it satisfies the above three conditions. If yes, then it represents a Ring Topology otherwise not.
Below is the implementation of the above approach:
Time Complexity: O(V + E) where V and E are the numbers of vertices and edges in the graph respectively.
- Check if the given graph represents a Bus Topology
- Check if the given graph represents a Star Topology
- Check if given path between two nodes of a graph represents a shortest paths
- Check for star graph
- Check whether a given graph is Bipartite or not
- Check if a given graph is tree or not
- Check if a given graph is Bipartite using DFS
- Check if the given permutation is a valid DFS of graph
- Check if a directed graph is connected or not
- Check if a given tree graph is linear or not
- Check if removing a given edge disconnects a graph
- Check if a graph is strongly connected | Set 1 (Kosaraju using DFS)
- Check if there is a cycle with odd weight sum in an undirected graph
- Check if there exists a connected graph that satisfies the given conditions
- Check whether given degrees of vertices represent a Graph or Tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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 : mohit kumar 29