CMSC 250 Discrete Structures: Graphs and Trees
CMSC 250 Discrete Structures: Graphs and Trees
Discrete Structures
Graphs and Trees
Graphs
Vertices
Edges (endpoints)
Weighted – each
edge has a value
associated with it
Unweighted
24 July 2007 Graphs and Trees 3
Examples
http://richard.jones.name/google-hacks/google-cartography/google-cartography.html
http://en.wikipedia.org/wiki/Traveling_Sal
esman_Problem
24 July 2007 Graphs and Trees 19
TSP
One way to solve the general problem is to:
– Write down all Hamiltonian circuits
– Compute total distance for each
– Pick one for which total is minimal
What if graph has 30 vertices:
– 29! =8.84 x 1030 different Hamiltonian circuits
– If each circuit could be found and total distance
computed in a nanosecond, then would take:
2.8 x 1014 years!!!
– No known algorithm that is more efficient!!!
– Some that find “pretty good” solutions
24 July 2007 Graphs and Trees 20
Matrix Representations of Graphs
=
≅
≈
≠