Route Inspection

Route Inspection
Which
Whichof
ofthese
thesecan
canbe
bedrawn
drawnwithout
withouttaking
takingyour
yourpencil
penciloff
off
the
thepaper
paperand
andwithout
withoutgoing
goingover
overthe
thesame
sameline
linetwice?
twice?
IfIfwe
weintroduce
introduceaavertex
vertexwhere
wheretwo
twolines
linesmeet
meetand
andmake
makethe
the
lines
linesedges,
edges,then
thenwe
wecan
canmodel
modelthese
theseproblems
problemsas
asgraphs.
graphs.




IfIfwe
wecan
canfind
findaapath
paththat
thatgoes
goesover
overall
allthe
theedges
edgesof
ofthe
thegraph
graphwithout
without
repeating
an
edge
then
the
graph
is
said
to
be
traversable.
repeating an edge then the graph is said to be traversable.
Route Inspection
Whether
Whetheror
ornot
notaagraph
graphisistraversable
traversabledepends
dependson
onthe
thenumber
number
of
ofedges
edgesthat
thatmeet
meetat
atthe
thevertices.
vertices. The
Thenumber
numberof
ofedges
edgesthat
that
meet
meetat
ataavertex
vertexisiscalled
calledthe
thedegree
degreeof
ofthat
thatvertex.
vertex.
Odd
Degree
Degree33
Odd
Even
Degree
Degree22
Even
Odd
Degree
Degree33
Odd
Even
Degree
Even
Degree22
An
Anodd
oddvertex
vertexisisone
onewith
withan
anodd
odddegree.
degree.
An
Aneven
evenvertex
vertexisisone
onewith
withan
aneven
evendegree.
degree.
Route Inspection
AAgraph
graphwith
withonly
onlyeven
evenvertices
verticesisistraversable
traversableand
andwe
wecan
canstart
startand
and
finish
at
the
same
vertex.
Such
a
graph
is
called
Eulerian.
finish at the same vertex. Such a graph is called Eulerian.
All
Allvertices
verticeseven
even––
Eulerian
Euleriangraph.
graph.
Route Inspection
AAgraph
graphwith
withexactly
exactly22odd
oddvertices
verticesisistraversable
traversableas
aslong
longas
aswe
we
start
starton
onone
oneof
ofthe
theodd
oddvertices
verticesand
andfinish
finishat
atthe
theother
otherone.
one.Such
Suchaa
graph
graphisiscalled
calledSemi-Eulerian.
Semi-Eulerian.
22odd
oddvertices
vertices––
Semi-Eulerian
Semi-Eulerian
All
Allvertices
verticeseven
even––
Eulerian
Euleriangraph.
graph.
Route Inspection
AAgraph
graphwith
withmore
morethan
thantwo
twoodd
oddvertices
verticesisisnot
nottraversable.
traversable.
44odd
oddvertices
vertices––
not
nottraversable
traversable
22odd
oddvertices
vertices––
Semi-Eulerian
Semi-Eulerian
All
Allvertices
verticeseven
even––
Eulerian
Euleriangraph.
graph.
Route Inspection
Which
Whichtype
typeof
ofgraph
graphisisthe
theone
oneon
onthe
thefar
farright?
right?
44odd
oddvertices
vertices––
not
nottraversable
traversable
22odd
oddvertices
vertices––
Semi-Eulerian
Semi-Eulerian
All
Allvertices
verticeseven
even––
Eulerian
Euleriangraph.
graph.
Two
Twoodd
oddvertices
vertices
- -Semi-Eulerian
Semi-Eulerian
Route Inspection
Consider
Considernow
nowaanetwork
networkwith
withweights
weightsassociated
associatedwith
withthe
theedges.
edges. The
The
route
routeinspection
inspectionproblem
problemisisto
tofind
findaapath
paththrough
throughthe
thenetwork
networkthat
that
includes
includesevery
everyedge
edgeat
atleast
leastonce
onceand
andhas
hasthe
theminimum
minimumtotal
totalweight.
weight.
Postman
PostmanPat
Pathas
hasto
todeliver
deliveralong
alongeach
eachof
ofthe
theroads
roadsin
inthe
thenetwork
network
below.
What
is
his
minimum
total
distance?
below. What is his minimum total distance?
8
B
5
G
4
3
7
C
2
D
E
A
7
5
6
3
4
F
6
Route Inspection
All
Allthe
thevertices
verticesare
areeven
even––the
thenetwork
networkisisEulerian
Eulerian––so
soany
anyroute
routethat
that
traverses
traversesthe
thegraph
graphwill
willsuffice.
suffice.
An
Anexample
exampleof
ofone
onesuch
suchpath
pathout
outof
ofthe
themany
manyis:
is:
AEBCDFEDBGCFA
AEBCDFEDBGCFA
8
B
5
G
4
3
7
C
2
D
E
A
7
5
6
3
4
6
F
The
Theminimum
minimumtotal
totaldistance
distanceisisjust
justthe
thesum
sumof
ofthe
theedges.
edges.
77++66++66++33++88++33++22++55++44++77++44++55==60
60
Route Inspection
Another
Anotherroad
roadisisadded
addedto
toPat’s
Pat’sround.
round.
There
Thereare
arenow
now22odd
oddnodes,
nodes,AAand
andD,
D,so
sothe
thegraph
graphisisSemiSemiEulerian.
The
graph
is
still
traversable
if
we
start
at
one
Eulerian. The graph is still traversable if we start at oneof
ofthe
the
odd
nodes
and
finish
at
the
other
one.
odd nodes and finish at the other one.
8
B
5
G
4
3
7
C
2
D
7
A
12
5
6
3
E
4
F
6
Route Inspection
What
WhatififPat
Patneeds
needsto
tostart
startand
andfinish
finishat
atthe
thesame
sameplace?
place?
To
Tostart
startand
andfinish
finishat
atAAhe
hewill
willneed
needto
toget
getback
backfrom
fromDDto
toAAat
at
the
theend.
end. What
Whatisisthe
theshortest
shortestway
wayof
ofdoing
doingthis?
this?
We
Wecould
coulduse
useDijkstra’s
Dijkstra’sshortest
shortestpath
pathalgorithm
algorithmfor
forthis
thisbut
butfor
forthis
this
small
example
we
can
see
it
is
along
DEA,
adding
10
to
the
total
small example we can see it is along DEA, adding 10 to the totallength.
length.
8
B
5
G
4
3
7
C
2
D
7
A
12
5
6
3
E
4
F
6
Route Inspection
So
Soby
byrepeating
repeatingthe
theedges
edgesDE
DEand
andEA
EAwe
wecan
canstart
startat
atA,
A,cover
cover
every
everystreet
streetand
andget
getback
backto
toA.
A.
The
Thetotal
totaldistance
distance ==sum
sumof
ofall
allthe
theedges
edges++repeated
repeatededges
edges
==72
72++(3
(3++7)
7)
==82
82
8
B
5
G
4
3
7
C
2
D
7
A
12
5
6
3
E
4
6
F
One
Oneof
ofthe
themany
manyalternative
alternativeroutes
routesthat
thatgive
givethis
thistotal
totalis:
is:
AEBGCFEDBCDFGDEA
AEBGCFEDBCDFGDEA
Route Inspection
To
his
rounds
and
finish
at
Tocomplete
complete
his
rounds
and
finish
atthe
theplace
placehe
hestarted,
started,he
hewill
willhave
have
Suppose
now
another
road
is
added,
FG.
Suppose
now
another
road
is
added,
FG.
to
torepeat
repeatone
oneof
ofthe
thefollowing
followingpairs
pairsof
ofpaths
paths
We
have
odd vertices A, D, F and G.
We
G
––now
Fnow
DD––four
Afour
G
Fand
andhave
A odd vertices A, D, F and G.
We
have
to
consider
all
the
ways
of
pairing
up
these
four
We
have
to
consider
all
the
ways
of
pairing
up
these
four
G
–
D
and
F
–
A
G – D and F – A
vertices.
vertices.
GG––AAand
andDD––FF
Which
Whichof
ofthese
thesepairings
pairingsadds
addsthe
theleast
leastamount
amountof
ofextra
extradistance?
distance?
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
To
Tocomplete
completehis
hisrounds
roundsand
andfinish
finishat
atthe
theplace
placehe
hestarted,
started,he
hewill
willhave
have
to
torepeat
repeatone
oneof
ofthe
thefollowing
followingpairs
pairsof
ofpaths
paths
GG––FFand
andDD––AA == 66++(7
(7++3)
3) ==16
16
GG––DDand
andFF––AA
GG––AAand
andDD––FF
Which
Whichof
ofthese
thesepairings
pairingsadds
addsthe
theleast
leastamount
amountof
ofextra
extradistance?
distance?
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
To
Tocomplete
completehis
hisrounds
roundsand
andfinish
finishat
atthe
theplace
placehe
hestarted,
started,he
hewill
willhave
have
to
torepeat
repeatone
oneof
ofthe
thefollowing
followingpairs
pairsof
ofpaths
paths
GG––FFand
andDD––AA
GG––DDand
andFF––AA
==
==
66++(7
(7++3)
3) ==16
16
(5
(5++4)
4)++66 ==15
15
GG––AAand
andDD––FF
Which
Whichof
ofthese
thesepairings
pairingsadds
addsthe
theleast
leastamount
amountof
ofextra
extradistance?
distance?
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
To
Tocomplete
completehis
hisrounds
roundsand
andfinish
finishat
atthe
theplace
placehe
hestarted,
started,he
hewill
willhave
have
to
torepeat
repeatone
oneof
ofthe
thefollowing
followingpairs
pairsof
ofpaths
paths
GG––FFand
andDD––AA
GG––DDand
andFF––AA
==
==
66++(7
(7++3)
3) ==16
16
(5
(5++4)
4)++66 ==15
15
GG––AAand
andDD––FF == (6
(6++6)
6)++55 ==17
17
Which
Whichof
ofthese
thesepairings
pairingsadds
addsthe
theleast
leastamount
amountof
ofextra
extradistance?
distance?
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
To
Tocomplete
completehis
hisrounds
roundsand
andfinish
finishat
atthe
theplace
placehe
hestarted,
started,he
hewill
willhave
have
to
torepeat
repeatone
oneof
ofthe
thefollowing
followingpairs
pairsof
ofpaths
paths
GG––FFand
andDD––AA
GG––DDand
andFF––AA
==
==
66++(7
(7++3)
3) ==16
16
(5
(5++4)
4)++66 ==15
15
GG––AAand
andDD––FF == (6
(6++6)
6)++55 ==17
17
The
Themiddle
middlepairing
pairingadds
addsthe
theleast
leastamount
amountof
ofextra
extradistance.
distance.
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
GG––DDand
andFF––AA == (5
(5++4)
4)++66 ==15
15
The
Thetotal
totaldistance
distance ==sum
sumof
ofall
allthe
theedges
edges++repeated
repeatededges
edges
==
==
78
78++15
15
93
93
We
Wecan
canmake
makeititeasier
easierto
tofind
findaaroute
routeby
bydrawing
drawingin
inextra
extraedges
edgeson
onthe
the
repeated
route.
repeated route.
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
An
Anexample
exampleroute
routeis:
is:
AFCDFEGDEBDBGBCGFA,
AFCDFEGDEBDBGBCGFA,total
totallength
length93.
93.
8
B
5
G
4
3
7
2
D
7
6
6
A
12
5
C
3
E
4
F
6
Route Inspection
Summary
Summary
Graph
Odd
vertices
Repeated edges
0
None
2
The shortest path joining the
two odd vertices
4
Try all possible pairings of
the odd vertices and choose
the smallest combination.