Lecture 12 Graph
Lecture 12 Graph
4
Perhaps the first graph you
saw
Can we sent all the utilities to the three
houses without crossing wires?
Not possible!
5
The first graph theory
Königsberg
City in Germany
The first graph theory paper by Leonhard Euler
In 1736: Seven bridges of Königsberg
A town with 7 bridges and 4 pieces of land…
Not possible!
7
THE Bridges of the Konigsberg
This can be pictured as follows:
e1 e2 e4
B e3 D
e5 e6 e7
C
•Vertices
The question is whether
are V={A,B,C,D} a person
and edges are E=can plan a walk in
{e1,e2,e3,e4,e5,e6,e7}.
e1 such
and e2a way that hewith
is associated will the
cross each ofpair
unordered these bridges
(A,B), e5 and e6 is
once but
associated not(B,C),
with more e3than once. with (B,D), e4 is associated
is associated
with (A,D) and e7 is associated with (C,D) and so on.
Definition - Graphs
9
Vertex Edge Graph
12
Example of a Simple Graph
= {{FL,GA},{FL,AL},{FL,MS},
{FL,LA}, {GA,AL}, {AL,MS},
{MS,LA}, {GA,SC}, {GA,TN},
{SC,NC}, {NC,TN}, {MS,TN},
{MS,AL}}
13
Multigraphs
A multigraph:
multiple edges connecting same nodes
14
Pseudographs
Pseudograph:
Like a multigraph, but edges connecting a node to itself are
allowed.
Simple Graph+ multiedge+ loop
15
Directed Graphs
A directed graph (V,E) consists of a set of vertices V and
a set of directed edges E on V : ordered pairs of
elements (u,v), u,v ∈ V.
Note: loop are allowed in a directed graph.
18
Types of Graphs: Summary
Summary of the book’s definitions.
Keep in mind this terminology is not fully
standardized across different authors...
19
Graph Models
• Graphs are used in a wide variety of models
• We now describe some diverse graph models for
some interesting applications
20
Graph Theory Application
1. Assignment of jobs to employees of an organization
2. The outcomes of round-robin tournaments.
3. To model acquaintanceship between people
4. Telephone calls between telephone numbers, and links
between websites.
5. To walk down all the streets in a city without going down a
street twice
6. Circuit board.
7. Two chemical compounds with the same molecular formula but
different structures using graphs.
8. Computer networks.
22
Graph Models: Social Networks
• Graphs can be used to model social structures based on
different kinds of relationships between people or groups.
• In a social network, vertices represent individuals or
organizations and edges represent relationships between
them.
• Useful graph models of social networks include:
friendship graphs - undirected graphs where two people are
connected if they are friends (in the real world, on Facebook, or in a
particular virtual world, and so on.)
collaboration graphs - undirected graphs where two people are
connected if they collaborate in a specific way
influence graphs - directed graphs where there is an edge from one
person to another if the first person can influence the second person
23
SOCIAL NETWORKS
Acquaintanceship Graphs
• Represent whether two people know each other,
that is, whether they are acquainted.
• Each person in a particular group of people is
represented by a vertex.
• Undirected edge is used to connect two people
when these people know each other.
• No multiple edges are used.
• Usually no loops are used.
• (If we want to include the notion of self-
knowledge, we would include loops.) 24
Example
25
26
An influence graph
A directed edge (a, b) means a can influence b.
E.g. (Fred, Brian) means Fred can influence
Brian.
27
Collaboration Graphs
• Academic
• Non-Academic
28
Graph Models:
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.
29
Graph Models:
Computer Networks
• To model a computer network where we care about the
number of links between data centers,
we use a multigraph.
30
Graph Models:
Computer Networks
• To model a computer network with diagnostic
links at data centers,
we use a pseudograph, as loops are needed.
31
Graph Models:
Computer Networks
• To model a network with multiple one-way links,
we use a directed multigraph.
• Note that
we could use a directed graph without multiple edges
if we only care whether there is at least one link from
a data center to another data center.
32
Call Graphs
33
Call Graphs (2)
35
TOURNAMENTS
Round Robin Tournaments
• A tournament where every team plays every other
team exactly once.
• Such tournaments can be modeled using directed
graphs where each team is represented by a
vertex.
• Note that (a, b) is an edge if team ‘a’ beats team
‘b’.
• This graph is a simple directed graph, containing no
loops or multiple directed edges.
36
• Team 1 is undefeated in this tournament, and
Team 3 is winless.
37
A Single-Elimination Tournament
38
Question
• Can you find a subject to which graph theory has
not been applied?
39
10.2 Graph Terminology
40
Graph Terminology
Adjacency:
Let G be an undirected graph with edge set E.
Let e ∈ E be (or map to) the pair {u,v}.
Then we say:
u, v are adjacent / neighbors / connected.
Edge e is incident with vertices u and v.
Edge e connects u and v.
Vertices u and v are endpoints of edge e.
41
Neighborhood of a Vertex
Let G be an undirected graph, v ∈ V a vertex.
The neighborhood of v, N(v), is the set of all
neighbors.
N(a) = {b, c}
N(b) = {a, b, c}
N(c) = {a, b, d}
N(d) = {d, c}
N(e) = {}
42
Degree of a Vertex
Let G be an undirected graph, v ∈ V a vertex.
The degree of v, deg(v), is its number of
incident edges. (Note: self-loops are counted
twice and have degree 2.)
deg(a) = 3
deg(b) = 3 + 2 = 5
deg(c) = 5
deg(d) = 3 + 2 = 5
deg(e) = 0 (isolated vertex)
44
EXAMPLE
• The degrees:
– deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, and
deg(d ) = 5.
• The neighborhoods
– N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b},
N(d) = {a, b, e}, and N(e) = {a, b, d}.
45
46
47
48
The Handshaking Theorem
*
(simple, multi, or pseudo) 49
Example
• deg(a)=3, deg(b)=5,
deg(c)=5, deg(d)=5,
deg(e)=0
50
EXAMPLE 3 at
Page# 653
• How many edges are there in a graph with 10
vertices each of degree six?
• deg(a) = deg(b) = deg(c) = … = deg(j) = 6
According to Handshaking Theorem,
deg(v) 2 E
vV
53
Directed Degree
deg+(a)= 4 deg-(a)= 2
deg+(b)= 1 deg-(b)= 2
deg+(c)= 2 deg-(c)= 3
deg+(d)= 2 deg-(d)= 2
deg+(e)= 3 deg-(e)= 3
deg+(f)= 0 deg-(f)= 0
55
Directed Handshaking
Theorem
Let G be a directed (possibly multi-) graph with
vertex set V and edge set E. Then:
57