Given a graph G, the task is to check if it represents a Star Topology.
A Star Topology is the one shown in the image below:
Input : Graph = Output : YES Input : Graph = Output : NO
A graph of V vertices represents a star topology if it satisfies the following three conditions:
- One node (also called the central node) has degree V – 1.
- All nodes except the central node have degree 1.
- No of edges = No of Vertices – 1.
The idea is to traverse the graph and check if it satisfies the above three conditions. If yes, then it represents a Star Topology.
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 Ring Topology
- Check for star graph
- Check if a given graph is tree or not
- Check whether a given graph is Bipartite 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 given tree graph is linear or not
- Check if a directed graph is connected or not
- 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)
- Check if removing a given edge disconnects a graph
- 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)
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.