Ring topology
Updated: 11/13/2018 by Computer Hope
A ring topology is a network configuration where device connections create a circular data path. Each networked device is connected to two others, like points on a circle. Together, devices in a ring topology are referred to as a ring network.
In a ring network, packets of data travel from one device to the next until they reach their destination. Most ring topologies allow packets to travel only in one direction, called a unidirectional ring network. Others permit data to move in either direction, called bidirectional.
The major disadvantage of a ring topology is that if any individual connection in the ring is broken, the entire network is affected.
Ring topologies may be used in either LANs [local area networks] or WANs [wide area networks]. Depending on the network card used in each computer of the ring topology, a coaxial cable or an RJ-45 network cable is used to connect computers together.
- Ring topology history.
- Advantages of a ring topology.
- Disadvantages of a ring topology.
- Related information.
Check if the given graph represents a Ring Topology
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:
Examples:
Input : Graph =Output : NO
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
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:
C++
// C++ program to check if the given graph // represents a Ring topology #include using namespace std; // A utility function to add an edge in an // undirected graph. void addEdge[vector adj[], int u, int v] { adj[u].push_back[v]; adj[v].push_back[u]; } // A utility function to print the adjacency list // representation of graph void printGraph[vector adj[], int V] { for [int v = 0; v < V; ++v] { cout Chủ Đề |