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 Star Topology
- Check if the given graph represents a Ring Topology
- Check if given path between two nodes of a graph represents a shortest paths
- Check whether a given graph is Bipartite or not
- Check if a given graph is Bipartite using DFS
- Check if a given graph is tree or not
- Check for star graph
- Check if the given permutation is a valid DFS of graph
- Check if a given tree graph is linear or not
- Check if a directed graph is connected or not
- Check if removing a given edge disconnects a graph
- Check if there is a cycle with odd weight sum in an undirected graph
- Check if a graph is strongly connected | Set 1 (Kosaraju using DFS)
- Two Clique Problem (Check if Graph can be divided in two Cliques)
- 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 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 : mohit kumar 29