0% found this document useful (0 votes)
2 views39 pages

Lecture_08_graph_02

The document provides an overview of various graph concepts, including undirected and directed graphs, their degrees, neighborhoods, and representations such as adjacency lists and matrices. It also discusses special types of graphs like bipartite graphs, Euler circuits, Hamiltonian paths, and trees, along with their definitions and properties. Additionally, it covers connectivity in graphs and the terminology related to rooted trees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views39 pages

Lecture_08_graph_02

The document provides an overview of various graph concepts, including undirected and directed graphs, their degrees, neighborhoods, and representations such as adjacency lists and matrices. It also discusses special types of graphs like bipartite graphs, Euler circuits, Hamiltonian paths, and trees, along with their definitions and properties. Additionally, it covers connectivity in graphs and the terminology related to rooted trees.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Graph

Lecture 8

1
Undirected graph
Example: What are the degrees and neighborhoods of the vertices in
the graphs H?

Solution:
H: deg(a) = ?, deg(b) = deg(e) = ?, deg(c) = 1, deg(d) = ?.
N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b},
N(d) = {a, b, e}, N(e) = {a, b ,d}.
2
Undirected graph
Example: What are the degrees and neighborhoods of the vertices in
the graphs H?

Solution:
H: deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, deg(d) = 5.
N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b},
N(d) = {a, b, e}, N(e) = {a, b ,d}.
3
Directed graph
Definition: The in-degree of a vertex v, denoted deg- (v), is
the number of edges which terminate at v. The out-degree of v,
denoted deg+(v), is the number of edges with v as their initial
vertex. Note that a loop at a vertex contributes 1 to both the indegree
and the out-degree of the vertex

Example: Assume graph G

deg- (a)=2, deg- (b)=2, deg- (c)=3,

deg- (d)=?, deg- (e)=?, deg- (f)=?

4
Directed graph
Definition: The in-degree of a vertex v, denoted deg- (v), is
the number of edges which terminate at v. The out-degree of v,
denoted deg+(v), is the number of edges with v as their initial
vertex. Note that a loop at a vertex contributes 1 to both the indegree
and the out-degree of the vertex

Example: Assume graph G

deg- (a)=2, deg- (b)=2, deg- (c)=2,

deg- (d)=2, deg- (e)=3, deg- (f)=0

5
Directed graph
Definition: The in-degree of a vertex v, denoted deg- (v), is
the number of edges which terminate at v. The out-degree of v,
denoted deg+(v), is the number of edges with v as their initial
vertex. Note that a loop at a vertex contributes 1 to both the indegree
and the out-degree of the vertex

Example: Assume graph G

Deg+ (a)=4, deg+ (b)=1, deg+ (c)=2,

deg+ (d)=?, deg+ (e)=?, deg+ (f)=?

6
Directed graph
Definition: The in-degree of a vertex v, denoted deg- (v), is
the number of edges which terminate at v. The out-degree of v,
denoted deg+(v), is the number of edges with v as their initial
vertex. Note that a loop at a vertex contributes 1 to both the indegree
and the out-degree of the vertex

Example: Assume graph G

Deg+ (a)=4, deg+ (b)=1, deg+ (c)=2,

deg+ (d)=2, deg+ (e)=3, deg+ (f)=0

7
Bipartite Graph
Definition: A simple graph G is bipartite if V can be partitioned
into two disjoint subsets V1 and V2 such that every edge connects a
vertex in V1 and a vertex in V2. In other words, there are no edges
which connect two vertices in V1 or in V2.

8
Bipartite Graph
Example: Show that C6 is bipartite.

9
Bipartite Graph
Example: Show that C3 is not bipartite.

Solution: If we divide the vertex set of C3 into two


nonempty sets, one of the two must contain two vertices.
But in C3 every vertex is connected to every other
vertex. Therefore, the two vertices in the same partition
are connected. Hence, C3 is not bipartite.

10
Representation: Adjacency List
Definition: An adjacency list can be used to represent a
graph with no multiple edges by specifying the vertices that
are adjacent to each vertex of the graph.

Example:
An adjacency list for a simple graph
vertex Adjacent vertex
a b, c, e
b a
c a, d, e
d c, e
e a, d, c
11
Representation: Adjacency List
Definition: An adjacency list can be used to represent a
graph with no multiple edges by specifying the vertices that
are adjacent to each vertex of the graph.

Example:
An adjacency list for a directed graph
vertex Adjacent vertex
a b, c, d, e
b b, d
c a, c, e
d
e b, c, d
12
Adjacency Matrix
Definition: Suppose that G = (V, E) is a simple graph where
|V| = n. Arbitrarily list the vertices of G as v1, v2, … , vn. The
adjacency matrix AG of G, with respect to the listing of
vertices, is the n × n zero-one matrix with 1 as its (i, j)th
entry when vi and vj are adjacent, and 0 as its (i, j)th entry
when they are not adjacent.

Example:
0 1 1 1
1 0 1 0

1 1 0 0
 
1 0 0 0
13
Adjacency Matrix
Adjacency matrices can also be used to represent graphs with loops
and multiple edges.
• A loop at the vertex vi is represented by a 1 at the (i, i)th position of
the matrix.
• When multiple edges connect the same pair of vertices vi and vj, (or if
multiple loops are present at the same vertex), the (i, j)th entry equals
the number of edges connecting the pair of vertices.

Example: The adjacency matrix of the pseudograph shown here using


the ordering of vertices a, b, c, d.

0 3 0 2
3 0 1 1 

0 1 1 2
 
2 1 2 0 14
Graph Isomorphism
Definition: The simple graphs G1 = (V1, E1) and G2 = (V2, E2) are
isomorphic if there is a one-to-one and onto function f from V1 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 G2 , for all a and b in V1 . Such a
function f is called an isomorphism. Two simple graphs that are not
isomorphic are called nonisomorphic.

one-to-one correspondence between vertices of the two graphs that


preserves the adjacency relationship

Are the two graph isomorphic?

15
Path
A path in a graph is a continuous way of getting
from one vertex to another by using a sequence of
edges.

16
Path Length
A path of length n in an undirected graph is a
sequence of n edges e1, e2, … ,en such that each
consecutive pair ei , ei+1 share a common vertex.

17
Path and Cycle
A simple path contains no duplicate edges
(though duplicate vertices are allowed). A cycle
(or circuit) is a path which starts and ends at the
same vertex.

18
Connectivity
Let G be a dograph. Let u and v be vertices. u
and v are connected to each other if there is a
path in G which starts at u and ends at v. G is said
to be connected if all vertices are connected to
each other.

19
Connectivity in directed graph
1) Weakly connected : can get from a to b in
underlying undirected graph
2) Strongly connected : there is a path from a to
b AND from b to a in the digraph

Weekly connected strongly connected 20


Euler Circuit

An Euler circuit in a graph G is a simple circuit


containing every edge of G.

A connected graph contains an Eulerian Circuit if and


only if every vertex has even degree.
21
Euler Path

An Euler path in G is a simple path containing every


edge of G.

A connected graph contains an Eulerian Path if and


only if exactly 2 vertices have odd degree.

22
Hamiltonian Circuit Problem

• Hamiltonian Circuit – a simple cycle including all the


vertices of the graph

23
Hamilton Path
• A Hamilton path of a graph or digraph is a path that
contains each vertex exactly once, except that the end
vertices may be the same.
• A Hamilton circuit (or cycle) is a Hamilton path that is a
cycle.
• Contrast this with an Euler circuit which contains each
edge exactly once.

24
Tree
Definition: A tree is a connected undirected graph with no simple circuits.

Example:

25
Forest
Definition: A forest is a graph that has no simple circuit, but is not
connected. Each of the connected components in a forest is a tree.

Example:

26
Tree
Theorem: An undirected graph is a tree if and only if there is a
unique simple path between any two of its vertices.

Example:

27
Rooted Tree
Definition: A rooted tree is a tree in which one vertex has been
designated as the root and every edge is directed away from the
root.

Note: An unrooted tree can be converted into different rooted trees


when one of the vertices is chosen as the root.

28
Rooted Tree Terminology
If v is a vertex of a rooted tree other than the root, the parent of v is
the unique vertex u such that there is a directed edge from u to v.
When u is a parent of v, v is called a child of u. Vertices with the
same parent are called siblings.

Parent of g: a
Children of g: h,i,j
Sibling: b, f

29
Rooted Tree Terminology
The ancestors of a vertex are the vertices on the path from the root
to this vertex, excluding the vertex itself and including the root.
The descendants of a vertex v are those vertices that have v as an
ancestor.

Ancestor j: g, a
descendant j: l, m

30
Rooted Tree Terminology
A vertex of a rooted tree with no children is called a leaf. Vertices
that have children are called internal vertices.

Leafs: d, e, k, l, m
Examples of internal nodes: b, g, h

31
Rooted Tree Terminology
If a is a vertex in a tree, the subtree with a as its root is the
subgraph of the tree consisting of a and its descendants and all
edges incident to these descendants.

32
M-ary Tree
Definition: A rooted tree is called an m-ary tree if every internal
vertex has no more than m children. The tree is called a full m-ary
tree if every internal vertex has exactly m children. An m-ary tree
with m = 2 is called a binary tree.

33
Binary Tree
A binary tree is an ordered rooted where each internal
vertex has at most two children. If an internal vertex of a binary
tree has two children, the first is called the left child and the second
the right child. The tree rooted at the left child of a vertex is called
the left subtree of this vertex, and the tree rooted at the right child
of a vertex is called the right subtree of this vertex.

34
Review Graph
determine whether the given graph has an
Euler circuit.

If no Euler circuit exists, determine whether the graph


has an Euler path

35
Review Graph
determine whether the given graph has a
Hamilton circuit. If it does, find such a circuit.

36
37
38
Thank You

39

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy