Docsity

Lecture Notes on Graphs - Discrete Structures | CSCI 243, Study notes of Discrete Structures and Graph Theory

Partial preview of the text

Download Lecture Notes on Graphs - Discrete Structures | CSCI 243 and more Study notes Discrete Structures and Graph Theory in PDF only on Docsity!

10/23/

CSci 243

Discrete Structures

Lecture 20Graphs IV

10/23/

Outline^ • Weighted Graphs• Shortest Paths — Dijkstra’s Algorithm• Application: Traveling Salesman Problem• Planar Graphs and Euler’s Formula

10/23/

Example: Flight Costs

10/23/

Shortest Path^ • What is the cheapest fare for NY to SF?• What is the cheapest way to get from NY to SF?•

Shortest path: the path between two verticeswhich has the minimal total cost (length)

  • Can find the shortest path for unweighted graph

by making it a weighted graph with edge cost=

  • Dijkstra’s Algorithm finds the length of the

shortest path. (Slight mod gets the path too.)

10/23/

Dijkstra’s Algorithm Example

10/23/

Analysis of Dijkstra’s Algorithm^ • QC: What is the algorithmic complexity of the

algorithm?

  • QC: What change could you make to make the

average running time better?

  • QC: What change could you make to compute

the shortest path?

10/23/

Traveling Salesman Problem (cont)^ • TSP is NP-Complete• Recall NP-Complete = problems which can be

solved with nondeterministic poly-time algorithm(“difficult”—exponential in practice)

  • Exponential growth: 25 cities

f

3.1x

23

paths.

  • Is-A-Tautology is NP-Complete (same as SAT): -^

p,q,r exist so that

!

(p

(q

v

r)

v

p¶

r¶

q) = True?

  • We use heuristics for TSP, BDDs for SAT

10/23/

Next up… Graph Planarity, Coloring

10/23/

Quick Questions^ • Is C

n^

planar?

  • Is K

4

planar?

  • Is K

5

planar?

10/23/

Euler’s Formula^ •

Region: In a planar graph, the areas betweenedges:

• |R| = |E| – |V| + 2

10/23/

Proof of Euler’s Formula^ • Assume |R

| = |Ek

| – |Vk

| + 2 for Gk^

k

  • Add the k+1 connecting edge to get G

k+

-^

|E

| increases by 1k

  • Case 1: k+1 edge connects to 1 vertex in G

k

-^

No new regions, so |R

| is the samek

-^

New vertex increases V

, so |Ek^

| – |Vk

| stays samek^

  • Case 2: k+1 edge connects 2 vertices in G

k

-^

1 new region, so |R

| increases by onek

-^

No new vertex, so |E

| – |Vk

| increases by onek^