Lecture 18
Lecture 18
Discrete Mathematics
Instructor: Dr. Samra Kanwal
• Multi Graph
• Pseudo Graph
• Null Graph
• Complete Graph
• Regular Graph
Some Terminology
• In a simple graph each edge connects two different vertices and no two edges
connect the same pair of vertices.
• Multigraphs may have multiple edges connecting the same two vertices. When
m different edges connect the vertices u and v, we say that {u,v} is an edge of
multiplicity m.
• An edge that connects a vertex to itself is called a loop.
• A pseudograph may include loops, as well as multiple edges connecting the
same pair of vertices.
Remark:
• Graphs where the end points of an edge are not
ordered are said to be undirected graphs.
Some Terminology (continued)
Exampl
e:
multiplicity of (a,b) is 1 and the
In this directed multigraph the a b
multiplicity of (b,c) is 2.
c
Graph Terminology: Summary
• To understand the structure of a graph and to build a graph
model, we ask these questions:
• Are the edges of the graph undirected or directed (or both)?
• If the edges are undirected, are multiple edges present that connect the
same pair of vertices? If the edges are directed, are multiple directed
edges present?
• Are loops present?
10.1 Graphs and
Graph Models
• When we build a graph model, we use the appropriate type of graph to capture the
important features of the application.
• We illustrate this process using graph models of different types of computer networks.
In all these graph models, the vertices represent data centers and the edges represent
communication links.
• To model a computer network where we are only concerned whether two data
centers are connected by a communications link, we use a simple graph. This is the
appropriate type of graph when we only care whether two data centers are directly
linked (and not how many links there may be) and all communications links work in
both directions.
Graph Models:
Computer Networks (continued)
Example: This
precedence graph shows
which statements must
already have been
executed before we can
execute each of the six
statements in the
program.
Graph Terminology
and
Special Types of
Section 10.2
Graphs
Basic Terminology
Definition 1. Two vertices u, v in an undirected graph G are
called adjacent (or neighbors) in G if there is an edge e between
u and v. Such an edge e is called incident with the vertices u and
v and e is said to connect u and v.
Solution:
G: deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d ) = 1, deg(e) = 3, deg(g) = 0.
N(a) = {b, f }, N(b) = {a, c, e, f }, N(c) = {b, d, e, f }, N(d) = {c},
N(e) = {b, c , f }, N(f) = {a, b, c, e}, N(g) = .
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}.
Special Types of Graphs
and Computer Network
Architecture
Various special graphs play an important role in the design of computer
networks.
• Some local area networks use a star topology, which is a complete bipartite
graph K1,n ,as shown in (a). All devices are connected to a central control
device.
• Other local networks are based on a ring topology, where each device is
connected to exactly two others using Cn ,as illustrated in (b). Messages may
be sent around the ring.
• Others, as illustrated in (c), use a Wn – based topology, combining the
features of a star topology and a ring topology.
Paths
Informal Definition: 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. As the path travels along
its edges, it visits the vertices along this path, that is, the
endpoints of these.
• When the graph is simple, we denote this path by its vertex sequence
x0, x1, … , xn(since listing the vertices uniquely determines the path).
• The path is a circuit if it begins and ends at the same vertex (u = v)
and has length greater than zero.
• The path or circuit is said to pass through the vertices x1, x2, … , xn-1
and traverse the edges e1, … , en.
• A path or circuit is simple if it does not contain the same edge more
than once.
Paths (continued)
• b, c, f, e, b is a circuit of length 4.
• d, e, c, a is not a path because e is not connected to c.
CHI NY
SF DEN
ATL
LA
MIA
Weighted Graphs
MILES
BOS
2534 860
191
1855 722 NY
CHI
SF DEN 908
957
606
7 60
4
349 83
1090
2 45 1
ATL
LA 595
MIA
Weighted Graphs
FARES
BOS
$129 $79
$39
$99 $59 NY
CHI
SF DEN $ 69
$89
$ 79
$ 99
$39 $89 $129
ATL
LA
$ 69
MIA
Weighted Graphs
FLIGHT
TIMES
BOS
4:05
2:10
0:50
2:55 NY
CHI 1:50
SF DEN 2:10
2:20
1:55
1:4
2:45
0
1:15 2:00 3:50
ATL
LA
1:3
0
MIA
Weighted Graphs
• A weighted graph is a graph in which each edge (u, v) has a weight w(u, v). Each
weight is a real number.
• The length of a path in a weighted graph is the sum of the weights on the edges.
• Each node is given a temporary label denoting the length of the shortest path
from the start node so far.
• Once it is certain that no other shorter paths can be found, the temporary
label becomes a permanent label.
• At this point the shortest path is found by retracing the path backwards.
Dijkstra’s algorithm: example
D(v) D(w) D(x) D(y) D(z)
Step N'
0 u 7,u 3,u 5,u ∞ ∞
1 uw 6,w 5,u 11,w ∞
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
4 uwxvy 12,y
5 uwxvyz x
9
notes: 5
4
7
construct shortest path
8
tree by tracing
predecessor nodes u
3 w y z
ties can exist (can be 2
broken arbitrarily) 3
7 4
v
Dijkstra’s algorithm: another example
b 5 d 5 f
4 7
4 3 1
a 2 z
3 4
c 5 e 5 g