Graph-Data-Structure-Report
Graph-Data-Structure-Report
Sara S. Ali
04.12.2024
Data Structure Course
1
Introduction
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.
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.
In one more general sense of the term allowing multiple edges, a graph is an ordered triple
𝐺 = (𝑉, 𝐸, ϕ) comprising:
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 𝑥 ∼ 𝑦.
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.
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
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
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.
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