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

Graph-Data-Structure-Report

Uploaded by

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

Graph-Data-Structure-Report

Uploaded by

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

Graph Data Structure

Sara S. Ali
04.12.2024
Data Structure Course

Supervised by Dr. Dunia H. Hameed

1
Introduction

In discrete mathematics, particularly in graph theory, a graph is a structure consisting of a


set of objects where some pairs of the objects are in some sense "related". The objects are
represented by abstractions called vertices (also called nodes or points) and each of the related
pairs of vertices is called an edge (also called link or line). Typically, a graph is depicted in
diagrammatic form as a set of dots or circles for the vertices, joined by lines or curves for the
edges. (See Fig 1)

(Figure 1: A graph with six vertices and seven edges)

The edges may be directed or undirected. For example, if the vertices represent people at a party,
and there is an edge between two people if they shake hands, then this graph is undirected
because any person A can shake hands with person B only if B also shakes hands with A. In
contrast, if an edge from person A to person B means that A owes money to B, then this graph is
directed, because owing money is not necessarily reciprocated.

(Figure 2: A graph with three vertices and three edges.)

2
1. Graph Theory

In one restricted but very common sense of the term, a graph is an ordered pair
𝐺 = (𝑉, 𝐸) comprising:
● V, a set of vertices (also called nodes or points);
● 𝐸 ⊆ {{𝑥, 𝑦} | 𝑥, 𝑦 ∈ 𝑉 𝑎𝑛𝑑 𝑥 ≠ 𝑦}, a set of edges (also called links or lines),
which are unordered pairs of vertices (that is, an edge is associated with two
distinct vertices).
To avoid ambiguity, this type of object may be called precisely an undirected simple graph.

In the edge {𝑥, 𝑦} , the vertices x and y are called the endpoints of the edge. The edge is
said to join x and y and to be incident on x and on y. A vertex may exist in a graph and not
belong to an edge. Under this definition, multiple edges, in which two or more edges connect the
same vertices, are not allowed.

(Figure 3: Example of an undirected multigraph with 3 vertices, 3 edges and 4


loops.)

In one more general sense of the term allowing multiple edges, a graph is an ordered triple
𝐺 = (𝑉, 𝐸, ϕ) comprising:

● V, a set of vertices (also called nodes or points);


● E, a set of edges (also called links or lines);
● ϕ: 𝐸 → {{𝑥, 𝑦} | 𝑥, 𝑦 ∈ 𝑉 and 𝑥 ≠ 𝑦}, an incidence function mapping every edge to
an unordered pair of vertices (that is, an edge is associated with two distinct vertices).
To avoid ambiguity, this type of object may be called precisely an undirected multigraph.

A loop is an edge that joins a vertex to itself. Graphs as defined in the two definitions
above cannot have loops, because a loop joining a vertex 𝑥 to itself is the edge (for an undirected
simple graph) or is incident on (for an undirected multigraph) {𝑥, 𝑥} = {𝑥} which is not in
{{𝑥, 𝑦} | 𝑥, 𝑦 ∈ 𝑉 and 𝑥 ≠ 𝑦} To allow loops, the definitions must be expanded. For
undirected simple graphs, the definition of E should be modified to 𝐸 ⊆ {{𝑥, 𝑦} | 𝑥, 𝑦 ∈ 𝑉} .
Forundirected multigraphs, the definition of ϕ should be modified to
ϕ : 𝐸 → {{𝑥, 𝑦} | 𝑥, 𝑦 ∈ 𝑉}. To avoid ambiguity, these types of objects may be called

3
undirected simple graph permitting loops and undirected multigraph permitting loops
(sometimes also undirected pseudograph), respectively.

V and E are usually taken to be finite, and many of the well-known results are not true (or
are rather different) for infinite graphs because many of the arguments fail in the infinite case.
Moreover, V is often assumed to be non-empty, but E is allowed to be the empty set. The order
of a graph is |𝑉|, its number of vertices. The size of a graph is |𝐸|, its number of edges. The
degree or valency of a vertex is the number of edges that are incident to it, where a loop is
counted twice. The degree of a graph is the maximum of the degrees of its vertices. In an
undirected simple graph of order n, the maximum degree of each vertex is n − 1 and the
𝑛(𝑛−1)
maximum size of the graph is 2 .
The edges of an undirected simple graph permitting loops G induce a symmetric homogeneous
relation ∼ on the vertices of G that is called the adjacency relation of G. Specifically, for each
edge (x, y), its endpoints x and y are said to be adjacent to one another, which is denoted 𝑥 ∼ 𝑦.

2. Graph in Data Structure

A graph is a non-linear data structure made up of nodes or vertices and edges. The edges connect
any two nodes in the graph, and the nodes are also known as vertices.

Some of the Types Graphs in Data Structures

1. Finite Graph

The graph G=(V, E) is called a finite graph if the number of vertices and edges in the
graph is limited in number.

2. Infinite Graph

The graph G=(V, E) is called a finite graph if the number of vertices and edges in the
graph is interminable.

3. Trivial Graph

A graph G= (V, E) is trivial if it contains only a single vertex and no edges.

4. Simple Graph

If each pair of nodes or vertices in a graph G=(V, E) has only one edge, it is a simple
graph. As a result, there is just one edge linking two vertices, depicting one-to-one
interactions between two elements.

4
5. Multi Graph

If there are numerous edges between a pair of vertices in a graph G= (V, E), the graph is
referred to as a multigraph. There are no self-loops in a Multigraph.

6. Null Graph

It's a reworked version of a trivial graph. If several vertices but no edges connect them, a
graph G= (V, E) is a null graph.

7. Complete Graph

If a graph G= (V, E) is also a simple graph, it is complete. Using the edges, with n
number of vertices must be connected. It's also known as a full graph because each
vertex's degree must be n-1.

8. Pseudo Graph

If a graph G= (V, E) contains a self-loop besides other edges, it is a pseudograph.

9. Regular Graph

If a graph G= (V, E) is a simple graph with the same degree at each vertex, it is a regular
graph. As a result, every whole graph is a regular graph.

10. Weighted Graph

A graph G= (V, E) is called a labeled or weighted graph because each edge has a value or
weight representing the cost of traversing that edge.

Graphs in data structures are used to represent the relationships between objects. Every graph
consists of a set of points known as vertices or nodes connected by lines known as edges. The
vertices in a network represent entities.

The most frequent graph representations are the two that follow:

● Adjacency matrix
● Adjacency list

5
Real World Applications

1. Graphs are used in computer science to depict the flow of computation.


2. Users on Facebook are referred to as vertices, and if they are friends, there is an edge
connecting them. The Friend Suggestion system on Facebook is based on graph theory.
3. You come across the Resource Allocation Graph in the Operating System, where each
process and resource are regarded vertically. Edges are drawn from resources to assigned
functions or from the requesting process to the desired resource. A stalemate will develop
if this results in the establishment of a cycle.
4. Web pages are referred to as vertices on the World Wide Web. Suppose there is a link
from page A to page B that can represent an edge. This application is an illustration of a
directed graph.
5. Graph transformation systems manipulate graphs in memory using rules. Graph databases
store and query graph-structured data in a transaction-safe, permanent manner.

You might also like