DS-Lecture 14
DS-Lecture 14
(CS-104)
Lecture 14
Graphs
Today’s Lecture
Graphs
Directed Graphs
Simple Graphs
Complete Graphs
Complete Bipartite Graphs
Subgraphs
The Concept of Degree
Today’s Lecture
Subgraphs
The Concept of Degree
Walks, Trails, Paths and Circuits
Connectedness
Connected Components
Euler Circuits
Constructing an Euler Circuits
Graphs
Imagine an organization that wants to set up teams of three to
work on some projects. In order to maximize the number of people
on each team who had previous experience working together
successfully, the director asked the members to provide names of
their past partners. This information is displayed below both in a
table and in a diagram.
Cont…
Cont…
a. Write the vertex set and the edge set, and give a table showing the
edge-endpoint function.
b. Find all edges that are incident on v1, all vertices that are adjacent to
v1, all edges that are adjacent to e1, all loops, all parallel edges, all
vertices that are adjacent to themselves, and all isolated vertices.
Graphs: Examples (Contd….)
a. vertex set = {v1, v2, v3, v4, v5, v6} Edge-endpoint function
edge set = {e1, e2, e3, e4, e5, e6, e7}
Edge-endpoint function
Labeling Drawings to Show They Represent the Same Graph
Both drawings are representations of the graph with vertex set {v1, v2, v3,
v4, v5}, edge set {e1, e2, e3, e4, e5}, and edge-endpoint function as follows:
Directed Graphs
Directed Graphs: Examples of Graphs
Using a Graph to Represent Knowledge
What paper finish does the New York Times use?
Using a Graph to Solve a Problem: Vegetarians and Cannibals
Example
Draw all simple graphs with the four vertices {u, v, w, x} and two
edges, one of which is {u, v}.
Each possible edge of a simple graph corresponds to a subset of
two vertices. Given four vertices, there are 4C2 = 6 such subsets in
all: {u, v}, {u,w}, {u, x}, {v,w}, {v, x}, and {w, x}. Now one edge of the
graph is specified to be {u, v}, so any of the remaining five from this
list can be chosen to be the second edge. The possibilities are
shown on the next page.
Simple Graphs
Complete Graphs
Example
Complete Graphs on n Vertices: K1, K2, K3, K4, K5
The complete graphs K1, K2, K3, K4, and K5 can be drawn as follows:
Complete Graphs
Example
Complete Graphs on n Vertices: K1, K2, K3, K4, K5
The complete graphs K1, K2, K3, K4, and K5 can be drawn as follows:
Complete Bipartite Graphs
Complete Bipartite Graphs
Complete Bipartite Graphs: K3,2 and K3,3
SubGraphs
Example
SubGraphs
The Concept of Degree
The Concept of Degree
Degree of a Vertex and Total Degree of a Graph
Find the degree of each vertex of the graph G shown below. Then
find the total degree of G.
The Concept of Degree
SubGraphs
Example
SubGraphs
The Concept of Degree
The Concept of Degree
Degree of a Vertex and Total Degree of a Graph
Find the degree of each vertex of the graph G shown below. Then
find the total degree of G.
The Concept of Degree
Walks
Let G be a graph, and let v and w be vertices in G.
A walk from v to w is a finite alternating sequence of
adjacent vertices and edges of G. Thus a walk has the
form
v0e1v1e2 · · · vn−1envn,
Example
Contd…
Theorem
Let G be a graph.
a. If G is connected, then any two distinct vertices of G can be connected
by a path.
b. If vertices v and w are part of a circuit in G and one edge is removed
from the circuit, then there still exists a trail from v to w in G.
c. If G is connected and G contains a circuit, then an edge of the circuit
can be removed without disconnecting G.
Connected Component of a Graph
Contd…
Find all connected components of the following graph G.
G has three connected components: H1, H2, and H3 with vertex sets V1, V2,
and V3 and edge sets E1, E2, and E3, where