0% found this document useful (0 votes)
233 views

1 - Introduction To Graphs

Graphs are data structures consisting of vertices and edges connecting vertices. They can model relationships like social networks, road maps, and biological systems. A graph G consists of a set of vertices V and edges E. Edges can be directed or undirected. The degree of a vertex is the number of edges incident to it. Special graphs include complete graphs Kn, cycles Cn, wheels Wn, and n-cubes Qn.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
233 views

1 - Introduction To Graphs

Graphs are data structures consisting of vertices and edges connecting vertices. They can model relationships like social networks, road maps, and biological systems. A graph G consists of a set of vertices V and edges E. Edges can be directed or undirected. The degree of a vertex is the number of edges incident to it. Special graphs include complete graphs Kn, cycles Cn, wheels Wn, and n-cubes Qn.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Introduction to Graphs

Introduction
• Graphs are data structures consisting of
vertices and edges that connect these
vertices.

• Before going in details first of all we must


know the applications of graph
Applications of Graph
• to represent who influences whom in an
organization
• to model acquaintanceships between people
• to model roadmaps
• to represent the competition of different
species in an ecological niche
Applications of Graph
Using graph models, we can determine:
• whether it is possible to walk down all the streets
in a city without going down a street twice
• the number of colors needed to color the regions
of a map
• whether two computers are connected by a
communications link
• the shortest path between two cities in a
transportation network
Graph
• A graph G = (V, E) consists of V, a nonempty set
of vertices (or nodes) and E, a set of edges.
Each edge has either one or two vertices
associated with it, called its endpoints. An
edge is said to connect its endpoints.
Graph
The set of vertices V of a graph G may be infinite
• A graph with an infinite vertex set is called an
infinite graph
• A graph with a finite vertex set is called a finite
graph
Here, we consider only finite graphs
Graph
Terminologies
• A graph in which each edge connects two different vertices
and where no two edges connect the same pair of vertices is
called a simple graph.

• Multiple edges means more than one edge connecting the


same pair of vertices. These are called parallel edges.
• Graphs that contains some parallel edges are
called multigraphs.
Terminologies
• Edges that connect a vertex to itself are called
loops.
• Graphs that may include loops and multiple
edges are sometimes called pseudographs.
Terminologies
An edge which is associated with an unordered pair of
vertices is called an undirected edge
An undirected graph is a graph whose all edges are
undirected.

Eg.

(A,B) is same as (B,A)


It is called unordered pair as there is
no direction between vertex A and vertex B
Terminologies
An edge which is associated with an ordered pair
of vertices is called a directed edge
A directed graph is a graph whose all edges are
directed. Directed graph is also known as digraph.
Edges are directed by arrows.

Eg.
Since there is a direction between
Vertices. Vertices pairs are called ordered
pairs.
(A,B) is an ordered pair
(B,A) does not exist in this graph
Terminologies
• Formal Definition
• A directed graph (or digraph) (V, E) consists of a nonempty set of
vertices V and a set of directed edges (or arcs) E. Each directed edge is
associated with an ordered pair of vertices. The directed edge
associated with the ordered pair (u, v) is said to start at u and end at v.

• When a directed graph has no loops and has no multiple directed


edges, it is called as simple directed graph.

• Directed graphs that may have multiple directed edges from a vertex
to a second (possibly the same) vertex are called directed
multigraphs.
Terminologies
• When there are m directed edges, each
associated to an ordered pair of vertices (u, v),
we say that (u, v) is an edge of multiplicity m.

• A graph with both directed and undirected


edges is called a mixed graph
Terminologies
Terminologies
• Two vertices u and v in an undirected graph G
are called adjacent (or neighbors) in G if u and
v are endpoints of an edge of G. If e is
associated with {u, v}, the edge e is called
incident with the vertices u and v. The edge e
is also said to connect u and v. The vertices u
and v are called endpoints of an edge
associated with {u, v}.
Terminologies
• The degree of a vertex in an undirected graph
is the number of edges incident with it, except
that a loop at a vertex contributes twice to the
degree of that vertex. The degree of the
vertex v is denoted by deg(v).
• A vertex of degree zero is called isolated.
• A vertex is pendant if and only if it has degree
one.
Problem
• What are the degrees of the vertices in the
graphs G and H ?
THE HANDSHAKING THEOREM
• Let G = (V, E) be an undirected graph with e
edges. Then

Example

How many edges are there in a graph with 10 vertices each of degree six?

Solution: Because the sum of the degrees of the vertices is 6· lO = 60, it


follows that 2e = 60.
Therefore, e = 30.
Terminologies
• When (u, v) is an edge of the graph G with
directed edges, u is said to be adjacent to v
and v is said to be adjacent from u. The vertex
u is called the initial vertex of(u, v), and v is
called the terminal or end vertex of (u, v). The
initial vertex and terminal vertex of a loop are
the same.
Terminologies
In a graph with directed edges
• the in-degree of a vertex v, denoted by is
the number of edges with v as their terminal
vertex.
• The out-degree of v, denoted by is the
• number of edges with v as their initial vertex.
(Note that a loop at a vertex contributes I to
• both the in-degree and the out-degree of this
vertex.)
Theorem
• Let G = (V, E) be a graph with directed edges.
Then

The sum of the in-degrees and the sum of the out-


degrees of all vertices in a graph with directed edges
are the same. Both of these sums are the number of
edges in the graph.
Some Special Simple Graphs
• Complete Graphs The complete graph on n
vertices, denoted by Kn, is the simple graph
that contains exactly one edge between each
pair of distinct vertices. The graphs Kn, for n =
1,2, 3, 4, 5, 6, are as follows:
Some Special Simple Graphs
• Cycles The cycle Cn, n >= 3, consists of n
vertices v1, v2,...,vn and edges {v1, v2},
• {v2,v3},... ,{vn-1,vn}, and {vn,v1}. The cycles
C3, C4 , C5, and C6 are as follows:
Some Special Simple Graphs
• Wheels We obtain the wheel Wn, when we
add an additional vertex to the cycle Cn, for
n >=3, and connect this new vertex to each of
the n vertices in Cn, by new edges.The wheels
W3, W4,W5, and W6 are displayed as follows:
Some Special Simple Graphs
• n-Cubes The n-dimensional hypercube, or n-cube,
denoted by Qn, is the graph that has vertices representing the
2n bit strings of length n. Two vertices are adjacent if and only
if the bit strings that they represent differ in exactly one bit
position. The graphs Q1, Q2, and Q3 are displayed as follows:
n-Cubes continued..
• Note that you can construct the (n + I)-cube Qn+1 from the
n-cube Qn by making two copies of Qn, prefacing the
labels on the vertices with a 0 in one copy of Qn and with
a 1 in the other copy of Qn,
• and adding edges connecting two vertices that have labels
differing only in the first bit.
• Eg. Q3 is constructed from Q2 by drawing two copies of Q2
as the top and bottom faces of Q3, adding 0 at the
beginning of the label of each vertex in the bottom face
and 1 at the beginning of the label of each vertex in the
top face.

You might also like