Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
39 views

Data Structures Assignment

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Data Structures Assignment

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PROGRAM: INFORMATION TECHNOLOGY

INDEX NO: 022101921

GRAPH

In data structures, graphs are a collection of nodes or vertices connected by edges. They are
used to represent relationships and connections between different elements, allowing for
efficient modelling and analysis of complex systems. Graphs provide a powerful framework
for solving problems in various domains such as network a Graphs are powerful data
structures that represent real-life relationships between entities. Graphs are used everywhere,
from social networks, Google Maps, and the world wide web to blockchains and neural
networks. Due to their ability to provide abstractions to real-life, they are used in various
practical problems. This article will dive deep into graphs in the data structure, their types,
terminologies, operations, representation, and applications. analysis, social media analysis,
and route planning. Let us understand what is a graph in the data structure. Graphs are non-
linear data structures comprising a set of nodes (or vertices), connected by edges (or arcs).
Nodes are entities where the data is stored, and their relationships are expressed using edges.
Edges may be directed or undirected. Graphs easily demonstrate complicated relationships
and are used to solve many real-life problems.

Types of Graphs in Data Structure

The most common types of graphs in the data structure are below:

1. Undirected: A graph in which all the edges are bi-directional. The edges do not point in a
specific direction.

2. Directed: A graph in which all the edges are uni-directional. The edges point in a single
direction.

3. Weighted Graph: A graph with a value associated with every edge. The values
corresponding to the edges are called weights. A value in a weighted graph can represent
quantities such as cost, distance, and time, depending on the graph. We typically use
weighted graphs in modelling computer networks.
4. Unweighted Graph: A graph with no value or weight associated with the edge. All the
graphs are unweighted by default unless there is a value associated.

Graph Representation in Data Structure

Below are the two most common ways of representing graphs in data structure:

1. Adjacency Matrix

An Adjacency Matrix is the simplest way to represent a graph. It is a 2D array of V x V


vertices, with each row and column representing a vertex. The matrix consists of “0” or “1”.
0 depicts that there is no path, while 1 represents that there is a path.

2. Adjacency List
It represents a graph as an array (A) of linked lists. The vertices are stored as an index of the
one-dimension array, and the edges are stored as a list. It means that each element of the
array Ai is a list. It contains all the vertices adjacent to vertex .

Applications of Graphs in Data Structure

Graphs data structures have a variety of applications. Some of the most popular applications
are:
 It helps to define the flow of computation of software programs.
 Used in Google Maps for building transportation systems. In google maps, the
intersection of two or more roads represents the node while the road connecting two
nodes represents an edge. Google Maps algorithm uses graphs to calculate the shortest
distance between two vertices.
 Used in social networks such as Facebook and Linkedin.
 Operating Systems use a Resource Allocation Graph where every process and
resource acts as a node. While we draw edges from resources to the allocated process.
 Used in the world wide web where the web pages represent the nodes.
 Blockchains also use graphs. The nodes store many transactions while the edges
connect subsequent blocks.
 Used in modelling data.

You might also like