Ar23 Rec Ds Unit-V
Ar23 Rec Ds Unit-V
ENGINEERING COLLEGE
(AUTONOMOUS | VISAKHAPATNAM)
Syllabus:
Directed edges
Undirected edges
3) Regular graph:
A regular graph is a graph in which every vertex has the same degree.
Example:
A and C are
adjacent vertices
Graph G
Degree of a Vertex: The Degree of a Vertex in a graph is the number of
edges incident to that vertex. In a directed graph, the degree is further
categorized into the in-degree (number of incoming edges) and
out-degree (number of outgoing edges) of the vertex.
Directed Graph
Undirected Graph
Indegree(V1) = 1 Outdegree(V1) = 1
Degree(V1) = 2 Indegree(V2) = 2 Outdegree(V2) = 2
Degree(V2) = 2 Indegree(V3) = 1 Outdegree(V3) = 1
Degree(V3) = 3 Indegree(V4) = 2 Outdegree(V4) = 1
Degree(V4) = 1 Indegree(V5) = 1 Outdegree(V5) = 2
Step 3: Dequeue/delete node 0 from the front of queue and visit the
unvisited neighbours and enqueue/insert them into queue.
Step 4: Dequeue/delete node 1 from the front of queue and visit the
unvisited neighbours and enqueue/insert them into queue.
Step 5: Dequeue/delete node 2 from the front of queue and visit the
unvisited neighbors and enqueue/insert them into queue.
Step 6: Dequeue/delete node 3 from the front of queue and visit the
unvisited neighbours and enqueue/insert them into queue.
As we can see that every neighbours of node 3 is visited, so move to
the next node that are in the front of the queue.
Step 7: Dequeue/delete node 4 from the front of queue and visit the
unvisited neighbours and enqueue/insert them into queue.
As we can see that every neighbours of node 4 are visited, so move to
the next node that is in the front of the queue.
Step 3: Now, Node 1 at the top of the stack, so visit node 1 and pop it
from the stack and put all of its adjacent nodes which are not visited in
the stack.
Step 4: Now, Node 2 at the top of the stack, so visit node 2 and pop it
from the stack and put all of its adjacent nodes which are not visited
(i.e, 3, 4) in the stack.
Step 5: Now, Node 4 at the top of the stack, so visit node 4 and pop it
from the stack and put all of its adjacent nodes which are not visited in
the stack.
Step 6: Now, Node 3 at the top of the stack, so visit node 3 and pop it
from the stack and put all of its adjacent nodes which are not visited in
the stack.
Now, Stack becomes empty, which means we have visited all the nodes
and our DFS traversal ends.
Ex:
Explain the step-by-step procedure to traverse the graph shown
in Figure 1 using the DFS algorithm.
Applications of Graphs:
• Social media analysis: Social media platforms generate vast amounts of
data in real-time, which can be analyzed using graphs to identify trends,
sentiment, and key influencers. This can be useful for marketing, customer
service, and reputation management.
• Network monitoring: Graphs can be used to monitor network traffic in
real-time, allowing network administrators to identify potential
bottlenecks, security threats, and other issues. This is critical for ensuring
the smooth operation of complex networks.
• Financial trading: Graphs can be used to analyze real-time financial data,
such as stock prices and market trends, to identify patterns and make
trading decisions. This is particularly important for high-frequency trading,
where even small delays can have a significant impact on profits.
• Internet of Things (IoT) management: IoT devices generate vast amounts
of data in real-time, which can be analyzed using graphs to identify
patterns, optimize performance, and detect anomalies. This is important
for managing large-scale IoT deployments.
• Autonomous vehicles: Graphs can be used to model the real-time
environment around autonomous vehicles, allowing them to navigate
safely and efficiently. This requires real-time data from sensors and other
sources, which can be processed using graph algorithms.
• Disease surveillance: Graphs can be used to model the spread of infectious
diseases in real-time, allowing health officials to identify outbreaks and
implement effective containment strategies. This is particularly important
during pandemics or other public health emergencies.
The best example of graphs in the real world is Facebook. Each person on
Facebook is a node and is connected through edges. Thus, A is a friend of B. B
is a friend of C, and so on.