Sie sind auf Seite 1von 42

GRAPH

Learning Outcomes
Students should be able to:
Explain basic terminology of a graph
Identify Euler and Hamiltonian cycle
Represent graphs using adjacency matrices

Contents
Introduction
Paths and circuits
Matrix representations of graphs

Introduction to Graphs
DEF: A simple graph G = (V,E ) consists
of a non-empty set V of vertices (or
nodes) and a set E (possibly empty) of
edges where each edge is associated with
a set consisting of either one or two
vertices called its endpoints.
Q: For a set V with n elements, how many
possible edges there?

Terminology
Loop, parallel edges, isolated, adjacent
Loop - an edge connects a vertex to itself
Two edges connect the same pair of
vertices are said to be parallel.
Isolated vertex unconnected vertex.
Two vertices that are connected by an
edge are called adjacent.
An edge is said to be incident on each of
its end points.

Example of a graph

Vertex set = {u1, u2, u3}


Edge set = {e1, e2, e3, e4}
e1, e2, e3 are incident on u1
u2 and u3 are adjacent to u1
e4 is a loop
e2 and e3 are parallel

Types of Graphs
Directed order
counts when
discussing edges
Undirected
(bidirectional)

Weighted each
edge has a value
associated with it
Unweighted

18 November 2014

Graphs and Trees

Examples

http://richard.jones.name/google-hacks/google-cartography/google-cartography.html

18 November 2014

Graphs and Trees

Special Graphs
Simple does not have any loops or parallel
edges
Complete graphs there is an edge between
every possible tuple of vertices
Bipartite graph V can be partitioned into V1
and V2, such that:

(x,y)E (xV1 yV2) (xV2 yV1)

Sub graphs

G1 is a subset of G2 iff

Every vertex in G1 is in G2
Every edge in G1 is in G2

Connected graph can get from any vertex to


another via edges in the graph

18 November 2014

Graphs and Trees

Complete Graphs

there is an edge between every possible


tuple of vertices. |e| = C(n,2) = n. (n-1)/2

Bipartite graph

A graph is bipartite if its vertices can be


partitioned into two disjoint subsets U and
V such that each edge connects a vertex
from U to one from V.

10

Complete bipartite

A bipartite graph is a complete bipartite


graph if every vertex in U is connected to every
vertex in V. If U has m elements and V has n,
then we denote the resulting complete bipartite
graph by Km,n. The illustration shows K3,2

11

Degree of Vertex

Defined as the number of edges attached


(incident) to the vertex. A loop is counted twice.

18 November 2014

Graphs and Trees

12

Handshake Theorem
If G is any graph, then the sum of the
degrees of all the vertices of G equals
twice the number of edges of G.
Specifically, if the vertices of G are v1, v2,
, vn, where n is a nonnegative integer,
then:

The total degree of G = d(v1)+d(v2)++d(vn)


= 2 (the number of edges of G)

18 November 2014

Graphs and Trees

13

Total degree of a graph is even


Prove that the total of the degrees of all
vertices in a graph is even.
Since the total degree equals 2 times of
edges, which is an integer, the sum of all
degree is even.

18 November 2014

Graphs and Trees

14

Whether certain graphs exist


Draw a graph with the specified properties
or show that no such graph exists.
(a) A graph with four vertices of degrees
1,1,2, and 3
(b) A graph with four vertices of degrees
1,1,3 and 3
(c) A simple graph with four vertices of
degrees 1,1,3 and 3

15

Even no. of vertices with odd degree


In any graph, there are an even number
of vertices with odd degree
Is there a graph with ten vertices of
degrees 1,1,2,2,2,3,4,4,4, and 6?

18 November 2014

Graphs and Trees

16

Learning Outcomes
Students should be able to:
Explain basic terminology of a graph
Identify Euler and Hamiltonian cycle
Represent graphs using adjacency matrices

17

Seven Bridges of Knigsberg

Is it possible for a person to take a walk around


town, starting and ending at the same location and
crossing each of the seven bridges exactly once?
18 November 2014

Graphs and Trees

18

Definitions
Terminology - Walk, path, simple path,
circuit, simple circuit.
Walk from two vertices is a finite alternating
sequence of adjacent vertices and edges

Trivial walk from v to v consists of single vertex

v0e1v1e2envn

18 November 2014

Graphs and Trees

19

Path
Path a walk that does not contain a
repeated edge (may have a repeated
vertex)
v0e1v1e2envn where all the ei are distinct
Simple path a path that does not contain
a repeated vertex
v0e1v1e2envn where all the ei and vj are
distinct. e1 is represented by {v0,v1}.

20

Example - path

Path
v

Simple path

21

Circuit

Closed walk starts and ends at same


vertex

Circuit a closed walk without repeated


edge
Simple circuit a circuit with no repeated
vertex except first and last

22

Examples

Cuircuit

Simple circuit

23

Connectedness
Connectedness if there is a walk from
one to the other
Let G be a graph. Two vertices v and w of
G are connected if, and only if, there is a
walk from v to w.
The graph G is connected if, and only if,
given any two vertices v and w in G, there
is a walk from v to w.

24

Examples

25

Euler Circuits
A circuit that contains every vertex and
every edge of G.
A sequence of adjacent vertices and edges

that starts and ends at the same vertex,


uses every vertex of G at least once, and
uses every edge of G exactly once.

18 November 2014

Graphs and Trees

26

If every vertex of a graph has even degree


then the graph has an Euler circuit.

Contrapositive: if the graph does not have


an Euler circuit, then, some vertices have
an odd degree.

18 November 2014

Graphs and Trees

27

If every vertex of nonempty graph


has even degree and if graph is
connected, then the graph has an
Euler circuit.

18 November 2014

Graphs and Trees

28

Euler Circuit

A graph G has an Euler circuit if, and only


if, G is connected and every vertex of G
has even degree.

18 November 2014

Graphs and Trees

29

Hamiltonian Path
A path in an undirected graph which visits
each vertex exactly once.

18 November 2014

Graphs and Trees

30

Hamiltonian Circuit
A simple circuit that includes every vertex
of G.
A sequence of adjacent vertices and
distinct edges in which every vertex of G
appears exactly once, except for the first
and last, which are the same.

18 November 2014

Graphs and Trees

31

Hamiltonian circuit
An Euler circuit for a graph G may not be
a Hamiltonian circuit.
An Hamiltonian circuit may not be an Euler
circuit.

32

Hamiltonian Circuit
Proved simple criterion for determining
whether a graph has an Euler circuit
No analogous criterion for determining
whether a graph has a Hamiltonian circuit
Nor is there an efficient algorithm for
finding such an algorithm

18 November 2014

Graphs and Trees

33

Hamiltonian Circuit

Finding Hamiltonian circuits

34

Traveling Salesman Problem

http://en.wikipedia.org/wiki/Traveling_Sale
sman_Problem

18 November 2014

Graphs and Trees

35

Learning Outcomes
Students should be able to:
Explain basic terminology of a graph
Identify Euler and Hamiltonian cycle
Represent graphs using adjacency matrices

36

Matrix Representations of Graphs

18 November 2014

Graphs and Trees

37

Matrices and Digraph

Let G be a directed graph with ordered


vertices v1,v2,,vn. The adjacency matrix
of G is the n x n matrix A =(aij over the
set of nonnegative integers such that
aij = the numbers of arrows from vi to vj
for all i,j = 1,2,,n.

38

Matrices and Connected Components

18 November 2014

Graphs and Trees

39

Counting Walks of Length n

Matrix multiplication

18 November 2014

Graphs and Trees

40

How do these graphs relate?

18 November 2014

Graphs and Trees

41

Summary

42

Das könnte Ihnen auch gefallen