Given a graph G, check if it represents a Bus Topology.
A Bus Topology is the one shown in the image below:
Input: Output: YES Input: Output: NO
A graph of V vertices represents a bus topology if it satisfies the following two conditions:
- Each node except the stating end ending ones have degree 2 while the starting and ending have degree 1.
- No of edges = No of Vertices – 1.
The idea is to traverse the graph and check if it satisfies the above two conditions. If yes, then it represents a Bus Topology.
Below is the implementation of the above approach:
Time Complexity : O(E), where E is the number of Edges in the graph.
- Check if the given graph represents a Ring Topology
- Check if the given graph represents a Star Topology
- Check if a given graph is Bipartite using DFS
- Check for star graph
- Check whether a given graph is Bipartite or not
- Check if a given graph is tree or not
- Check if the given permutation is a valid DFS of graph
- Check if a given tree graph is linear or not
- Check if there is a cycle with odd weight sum in an undirected graph
- Check if removing a given edge disconnects a graph
- Check if a graph is strongly connected | Set 1 (Kosaraju using DFS)
- Check if a given directed graph is strongly connected | Set 2 (Kosaraju using BFS)
- Check whether given degrees of vertices represent a Graph or Tree
- Two Clique Problem (Check if Graph can be divided in two Cliques)
- Convert the undirected graph into directed graph such that there is no path of length greater than 1
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.