You are on page 1of 8

Graphs Eng.

Jehad Aldahdooh

Introduction To Graphs:

Definitions:

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 end points.
An edge is said to connect its endpoints.

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.

Exercises

1. Determine whether the graph shown has directed or undirected edges, whether it has multiple
edges, and whether it has one or more loops. Use your answers to determine the type of graph
in Table 1 this graph is.
Solution:

Type Comment
3 Simple graph Undirected edges, no parallel edges or loops
4 multigraph Undirected edges, no loops but a parallel edges
5 Pseudograph Undirected edges, with loops and parallel edges
6 multigraph Undirected edges, no loops but a parallel edges
7 directed graph Directed edges, no parallel edges but loops.
8 directed multigraph Directed edges, parallel edges and loops.
9 directed multigraph Directed edges, parallel edges and loops.

Graph Terminology

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}.
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).
o A vertex with degree 0 is called isolated.
o A vertex of degree 1 is called pendant.

THE HANDSHAKING THEOREM Let G = (V, E) be an undirected graph with e


edges. Then

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.

In a graph with directed edges the in-degree of a vertex v, denoted by deg-(v), is the
number of edges with v as their terminal vertex. The out-degree of v, denoted by
deg+(v), is the number of edges with v as their initial vertex.

Let G = (V, E) be a graph with directed edges. Then

The complete graph on n vertices, denoted by Kn, is the simple graph that contains
exactly one edge between each pair of distinct vertices.

For any n3, a cycle on n vertices, Cn, is a simple graph where V={v1,v2, ,vn} and
E={{v1,v2},{v2,v3},,{vn1,vn},{vn,v1}}.
For any n3, a wheel Wn, is a simple graph obtained by taking the cycle Cn and adding
one extra vertex vhub and n extra edges {{vhub,v1}, {vhub,v2},,{vhub,vn}}.
N-cubes: for any nN, the hypercube Qn is a simple graph consisting of two copies of
Qn-1 connected together at corresponding nodes. Q0 has 1 node.
Bipartite Graphs the graph can be divided into two parts in such a way that all edges
go between the two parts.
Complete Bipartite Graphs That is, there are m nodes in the left part, n nodes in
the right part, and every node in the left part is connected to every node
in the right part.
A subgraph of a graph G= (V, E) is a graph H= (W, F) where WV and FE.
The union G1G2 of two simple graphs G1=(V1, E1) and G2=(V2,E2) is the simple
graph (V1V2, E1E2).
Exercises

1. Find the number of vertices, the number of edges, and the degree of each
vertex in the given undirected graph. Identify all isolated and pendant
vertices.

Solution:

1) Graph 1
number of vertices: 6
the number of edges: 6
Vertex a b c d e f
Degree 2 4 1 0 2 3
isolated no no no yes no no
pendant no no yes no no no

2) graph 2
number of vertices: 5
the number of edges: 13
Vertex a b c d e
Degree 6 6 6 5 3
isolated no no no no no
pendant no no no no no

2. Determine the number of vertices and edges and find the in-degree and out-
degree of each vertex for the given directed multigraph.
Solution:

number of vertices: 4
the number of edges: 8
Vertex a b c d
In-degree 2 3 2 1
out-degree 2 4 1 1

3. How many vertices and how many edges do these graphs have?
a. Kn
b. Cn
c. Qn
d. Wn

Solution:

Kn Cn Qn Wn
vertices n n 2n n
Edges n(n-1)/2 n n2n/2 2n

4. Find the union of the given pair of simple graphs. (Assume edges with the
same endpoints are the same.)

Solution:
5. Determine whether the graph is bipartite.

Solution:

a) 19: the graph is bipartite, make to subset of V {e} and {a, b, c, d}


b) 22: the graph is bipartite, make to subset of V {c, f} and {a, b, d, e}

Representing Graphs and Graph Isomorphism.

The adjacency list of an undirected graph is simply a list of the vertices of the
given graph, together with a list of the vertices adjacent to each.
To form the adjacency list of a directed graph, we list, for each vertex in the
graph, the terminal vertex of each edge that has the given vertex as its initial
vertex.
Adjacency Matrices: Matrix A= [aij], where aij is 1 if {vi, vj} is an edge of G, and
is 0 otherwise.

The simple graphs G 1 = (VI, EI) and G2 = (V2, E2) are isomorphic if there is a
one-to-one and onto function f from VI to V2 with the property that a and b are
adjacent in G1 if and only if f(a) and f(b) are adjacent in G 2 , for all a and b in
VI. Such a function f is called an isomorphism. *

Necessary but not sufficient conditions for G1= (V1, E1) to be isomorphic to G2= (V2, E2):

o We must have that |V1|=|V2|, and |E1|=|E2|.


o The number of vertices with degree n is the same in both graphs.

Exercises

1. Use an adjacency list and adjacency matrix to represent the given graph.

Solution:

vertex Adjacent vertices


a b, d
b a, d, e
c e, d
d a, b, c
e b, c
Initial vertex terminal vertices
a b, d
b a, c, d, e
c b, c
d a, e
e c, e

2. Determine whether the given pair of graphs is isomorphic.

Solution:

a) Isomorphic, Mapping between vertices:


U1 U2 U3 U4 U5
V1 V2 V4 V5 V3

b) Not isomorphic, the first has 4 vertices with degree 3, but the second has only 3.

Connectivity.

Informally, a path is a sequence of edges that begins at a vertex of a graph and


travels from vertex to vertex along edges of the graph.
An undirected graph is connected iff there is a path between every pair of distinct
vertices in the graph.
A connected component of a graph G is a connected subgraph of G that is not a
proper subgraph of another connected subgraph of G.
A directed graph is strongly connected if there is a path from a to b and from b to
a whenever a and b are vertices in the graph.
A directed graph is weakly connected if there is a path between every two
vertices in the underlying undirected graph.

You might also like