Graph in Datastructure
Graph in Datastructure
presented by:-
Ayush Chouhan (0101CS221040)
Understanding Graphs in
in Data Structures
A graph is a non-linear data structure that consists of nodes (vertices) connected by
connected by edges. Learn about different types of graphs, representation
representation techniques, traversal algorithms, and real-world applications.
applications.
Definition of Graphs
1 What is a Graph? 2 Types of Graphs
A graph is a collection of vertices and There are different types of graphs,
edges, where vertices represent entities including undirected graphs, directed
and edges represent relationships graphs, and weighted graphs, each
between them. serving unique purposes.
3 Representing a Graph
Graphs can be represented using adjacency matrices or adjacency lists, providing efficient ways
to store and manipulate graph information.
Graph Traversal Algorithms
1 Breadth-First Search (BFS)
BFS explores the graph starting at the root (source) node and visits all the neighboring
nodes before moving to the next level.
3 Applications of Graphs
Graphs find applications in various domains, such as social networks, modeling web
page relationships, and analyzing data interconnections.
Visualization of Graphs
Graph theory helps solve problems like MST algorithms find the minimum-weight
finding the most efficient route to visit connected subgraph of a graph, useful in
certain locations (Eulerian Path) or visiting network design, clustering analysis, and
all locations exactly once (Hamiltonian resource allocation.
Path).
3 Graph Coloring
Graph coloring is used in scheduling problems, register allocation, and map labeling, ensuring
that no adjacent nodes have the same color.
Graph Databases and Knowledge Graphs
3 Dijkstra's Algorithm
Finds the shortest path between two vertices in a weighted graph.
Discovering the Marvels of
Graphs
We'll explore the common operations that can be performed on graphs, a powerful
data structure used in many fields, from social networks to transportation systems.
Join me on this journey!
Graph Representation in Memory
2 Applications:
Dependency resolution, task scheduling, code compilation.
3 Algorithm:
Uses DFS and a stack to reverse the order of the vertices visited in post-order traversal.
Shortest Path Algorithms
2 Prim's Algorithm
Starts with a random vertex, continually adds the cheapest edge to a vertex that hasn't
been visited yet, and stops when all vertices have been visited.
3 Kruskal's Algorithm
Sorts edges by weight, starts with the smallest one, and adds edges only if they don't
form a cycle. Stops when all vertices have been visited.
Graph Connectivity and Strongly
Connected Components
Connectivity: Weakly Connected Components:
A graph is connected if there is a path
between every pair of vertices. The maximal subgraphs of a directed graph
that are connected when all edges are
treated as undirected. Decomposes the
graph into a forest of trees.
2 Applications:
Scheduling problems, register allocation in compilers, frequency assignment in wireless
networks.
3 Algorithms:
Greedy algorithms work well for many problems, while more complex techniques like
backtracking and constraint programming are used for others.
Types of Graph in Data
Structure
Discover the fascinating world of graph data structures. From basic types to
common algorithms and real-world applications.
Basic Types of Graphs
Undirected Graph Directed Graph
A graph where edges have no direction. A graph where edges have a direction.
Connections between nodes are Connections between nodes are
bidirectional. unidirectional.
Properties of Graphs
Weighted Graph Unweighted Graph Connected and
Disconnected Graphs
A graph where edges have A graph where edges have no
weights or values associated with weights or values associated with
them. them.
A connected graph has a path
between every pair of its vertices.
A disconnected graph has one or
more components that are not
connected.
Common Algorithms for Working with
Graphs
1 Breadth-first Search
An algorithm that explores all vertices of a graph from the starting vertex level by level.
2 Depth-first Search
An algorithm that explores as far as possible along each branch before backtracking.
3 Dijkstra's Algorithm
An algorithm that finds the shortest path between two vertices in a graph with non-negative
edge weights.
Real-world Applications of Graph Data
Structures