70
Graph Theory Part One

Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Graph TheoryPart One

Page 2: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Graph TheoryPart One

For those of you who have already

completed CS106B/X:

Page 3: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg

Page 4: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Chemical Bonds

http://4.bp.blogspot.com/-xCtBJ8lKHqA/Tjm0BONWBRI/AAAAAAAAAK4/-mHrbAUOHHg/s1600/Ethanol2.gif

Page 5: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

http://www.prospectmagazine.co.uk/wp-content/uploads/2009/09/163_taylor2.jpg

Page 6: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which
Page 7: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

What's in Common

● Each of these structures consists of● a collection of objects and● links between those objects.

● Goal: find a general framework for describing these objects and their properties.

Page 8: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A graph is a mathematical structurefor representing relationships.

A graph consists of a set of nodes connected by edges.

Page 9: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A graph is a mathematical structurefor representing relationships.

A graph consists of a set of nodes (or vertices) connected by edges (or arcs)

Page 10: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A graph is a mathematical structurefor representing relationships.

A graph consists of a set of nodes (or vertices) connected by edges (or arcs)

Nodes

Page 11: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A graph is a mathematical structurefor representing relationships.

A graph consists of a set of nodes (or vertices) connected by edges (or arcs)

Edges

Page 12: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Some graphs are directed.

On these sites, you can follow someone who doesn’t follow

you back.

A tournament diagram shows who

beat who.

Page 13: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

CAT SAT RAT

RANMAN

MAT

CAN

Some graphs are undirected.

Words that differ from each other by exactly

one letter.

On this site, if you are friends with someone, they are also friends

with you.Atoms that are

adjacent to each other in a molecule.

Page 14: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Going forward, we're exclusively focused on undirected graphs.

The term “graph” will mean undirected graphs with a finite number of nodes,

(unless specified otherwise).

Page 15: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Formalizing Graphs

● How might we define a graph mathematically?

● We need to specify● what the nodes in the graph are, and● which edges are in the graph.

● The nodes can be pretty much anything.● What about the edges?

Page 16: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Formalizing Graphs

● An unordered pair is a set {a, b} of two elements a ≠ b. (Remember that sets are unordered).● {0, 1} = {1, 0}

● An undirected graph is an ordered pair G = (V, E), where● V is a set of nodes, which can be anything, and● E is a set of edges, which are unordered pairs of nodes drawn

from V.● [For your reference, but remember we won’t be

focusing on them in this class] A directed graph is an ordered pair G = (V, E), where● V is a set of nodes, which can be anything, and● E is a set of edges, which are ordered pairs of nodes drawn

from V.

Page 17: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

● An unordered pair is a set {a, b} of two elements a ≠ b.● An undirected graph is an ordered pair G = (V, E), where

● V is a set of nodes, which can be anything, and● E is a set of edges, which are unordered pairs of nodes drawn from V.

● An unordered pair is a set {a, b} of two elements a ≠ b.● An undirected graph is an ordered pair G = (V, E), where

● V is a set of nodes, which can be anything, and● E is a set of edges, which are unordered pairs of nodes drawn from V.

Answer at PollEv.com/cs103 ortext CS103 to 22333 once to join, then a number.

Answer at PollEv.com/cs103 ortext CS103 to 22333 once to join, then a number.

How many of these drawings are of valid undirected graphs?How many of these drawings are of valid undirected graphs?

A

C

B

D

A

C

B

D

A

C

B

D

A

C

B

D

ABBBC

A

C

B

D

Page 18: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Self-Loops

● An edge from a node to itself is called a self-loop.● In undirected graphs, self-loops are generally not

allowed.● Can you see how this follows from the definition?

● In directed graphs, self-loops are generally allowed unless specified otherwise.

✓×

Page 19: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Standard Graph Terminology

Page 20: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

CAT SAT RAT

RANMAN

MAT

CAN

Two nodes are called adjacent if there is an edge between them.

Page 21: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

CAT SAT RAT

RANMAN

MAT

CAN

Two nodes are called adjacent if there is an edge between them.

Page 22: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Adjacent nodes

● Let G = (V, E) be a graph.● Intuitively, two nodes are adjacent if they're

linked by an edge.● Formally speaking, we say that two

nodes u, v ∈ V are adjacent if {u, v} ∈ E.

Page 23: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg

Page 24: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg

Page 25: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SF Sac

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

Page 26: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SF Sac

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

From

To

Page 27: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SLC

LA

SD

But

Mon

LV

Bar Flag

Nog

Phoe

SF Sac

Port

Sea

From

To

SF, Sac, Port, SeaSF, Sac, Port, Sea

Page 28: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

LA

SD

But

Mon

LV

Bar Flag

Nog

Phoe

SLCSF Sac

Port

Sea

From

To

SF, Sac, SLC, Port, SeaSF, Sac, SLC, Port, Sea

Page 29: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SD Nog

Port

SLC

LA

But

Mon

LV

Bar Flag

Phoe

SF Sac

Sea

From

To

SF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, SeaSF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, Sea

Page 30: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SD Nog

Port

SLC

LA

But

Mon

LV

Bar Flag

Phoe

SF Sac

Sea

From

To A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

SF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, SeaSF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, Sea

Page 31: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SD Nog

Port

SLC

LA

But

Mon

LV

Bar Flag

Phoe

SF Sac

Sea

From

To A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, SeaSF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, Sea

Page 32: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SD Nog

Port

SLC

LA

But

Mon

LV

Bar Flag

Phoe

SF Sac

Sea

From

To A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, SeaSF, Sac, LA, Phoe, Flag, Bar, LV, Mon, SLC, But, Sea

(This path has length 10, but

visits 11 cities.)

(This path has length 10, but

visits 11 cities.)

Page 33: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SF Sac

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Page 34: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SF Sac

Mon

LV

Bar Flag

LA

SD Nog

Phoe

Port

Sea But A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SLC

Sea, But, SLC, Port, SeaSea, But, SLC, Port, Sea

From/To

Page 35: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Flag

SF

SD Nog

Phoe

Sac

Mon

LV

Bar

LA

Port

Sea But A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SLC

Sac, Port, Sea, But, SLC, Mon, LV, Bar, LA, SacSac, Port, Sea, But, SLC, Mon, LV, Bar, LA, Sac

From/To

Page 36: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Flag

SF

SD Nog

Phoe

Sac

Mon

LV

Bar

LA

Port

Sea But A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SLC

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

Sac, Port, Sea, But, SLC, Mon, LV, Bar, LA, SacSac, Port, Sea, But, SLC, Mon, LV, Bar, LA, Sac

From/To

Page 37: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Flag

SF

SD Nog

Phoe

Sac

Mon

LV

Bar

LA

Port

Sea But A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SLC

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

Sac, Port, Sea, But, SLC, Mon, LV, Bar, LA, SacSac, Port, Sea, But, SLC, Mon, LV, Bar, LA, Sac

(This cycle has length nine and visits nine different cities.)

(This cycle has length nine and visits nine different cities.)

From/To

Page 38: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SF Sac

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Answer at PollEv.com/cs103 ortext CS103 to 22333 once to join, then A, …, or E.

Answer at PollEv.com/cs103 ortext CS103 to 22333 once to join, then A, …, or E.

How many paths in this graphare there from SF to LA?

A. 1B. 4C. 10D. 20E. None of these.

How many paths in this graphare there from SF to LA?

A. 1B. 4C. 10D. 20E. None of these.

Page 39: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

SF Sac

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Page 40: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Sac

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SF

SFSF

Page 41: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

Bar Flag

LA

SD Nog

Phoe

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

SF, SacSF, Sac

Page 42: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

Bar Flag

SD Nog

Phoe

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

LA

SF, Sac, LASF, Sac, LA

Page 43: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

Bar Flag

SD Nog

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

PhoeLA

SF, Sac, LA, PhoeSF, Sac, LA, Phoe

Page 44: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

Bar

SD Nog

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

PhoeLA

Flag

SF, Sac, LA, Phoe, FlagSF, Sac, LA, Phoe, Flag

Page 45: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

SD Nog

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

PhoeLA

FlagBar

SF, Sac, LA, Phoe, Flag, BarSF, Sac, LA, Phoe, Flag, Bar

Page 46: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

SD Nog

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

PhoeLA

FlagBar

SF, Sac, LA, Phoe, Flag, Bar, LASF, Sac, LA, Phoe, Flag, Bar, LA

Page 47: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

Port

Sea But

SLC

Mon

LV

SD Nog

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

SacSF

PhoeLA

FlagBar

SF, Sac, LA, Phoe, Flag, Bar, LASF, Sac, LA, Phoe, Flag, Bar, LA

Page 48: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Port

Sea But

SLC

Mon

LV

SD Nog

SacSF

PhoeLA

FlagBar

SF, Sac, LA, Phoe, Flag, Bar, LASF, Sac, LA, Phoe, Flag, Bar, LA

Page 49: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Port

Sea But

SLC

Mon

LV

SD Nog

SacSF

PhoeLA

FlagBar

SF, Sac, LA, Phoe, Flag, Bar, LASF, Sac, LA, Phoe, Flag, Bar, LA

(A path, not a simple path.)

(A path, not a simple path.)

Page 50: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Port

Sea But

SLC

Mon

LV

SD Nog

SacSF

PhoeLA

FlagBar

SF, Sac, LA, Phoe, Flag, Bar, LASF, Sac, LA, Phoe, Flag, Bar, LA

(This path has length six.)

(This path has length six.)

Page 51: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Port

Sea But

SLC

Mon

LV

SD Nog

SacSF

PhoeLA

FlagBar

Page 52: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Port

Sea But

SLC

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac

SacSac

Page 53: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Port

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Sac, SLCSac, SLC

Page 54: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Sac, SLC, PortSac, SLC, Port

Page 55: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Sac, SLC, Port, SacSac, SLC, Port, Sac

Page 56: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Sac, SLC, Port, Sac, SLCSac, SLC, Port, Sac, SLC

Page 57: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Sac, SLC, Port, Sac, SLC, PortSac, SLC, Port, Sac, SLC, Port

Page 58: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Sac, SLC, Port, Sac, SLC, Port, SacSac, SLC, Port, Sac, SLC, Port, Sac

Page 59: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

A simple cycle in a graph is cycle that does not repeat any nodes or edges except the first/last node.

A simple cycle in a graph is cycle that does not repeat any nodes or edges except the first/last node.Sac, SLC, Port, Sac, SLC, Port, SacSac, SLC, Port, Sac, SLC, Port, Sac

Page 60: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

A simple cycle in a graph is cycle that does not repeat any nodes or edges except the first/last node.

A simple cycle in a graph is cycle that does not repeat any nodes or edges except the first/last node.Sac, SLC, Port, Sac, SLC, Port, SacSac, SLC, Port, Sac, SLC, Port, Sac

(A cycle, not a simple cycle.)

(A cycle, not a simple cycle.)

Page 61: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A cycle in a graph is a path from a node back to itself. (By convention, a cycle cannot have length zero.)

A simple path in a graph is path that does not repeat any nodes or edges.

A simple path in a graph is path that does not repeat any nodes or edges.

The length of the path v₁, …, vₙis n – 1.

The length of the path v₁, …, vₙis n – 1.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

A simple cycle in a graph is cycle that does not repeat any nodes or edges except the first/last node.

A simple cycle in a graph is cycle that does not repeat any nodes or edges except the first/last node.Sac, SLC, Port, Sac, SLC, Port, SacSac, SLC, Port, Sac, SLC, Port, Sac

(This cycle has length 6.)

(This cycle has length 6.)

Page 62: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Page 63: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Page 64: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Page 65: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

PortFrom

To

Page 66: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

PortFrom

To

Page 67: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

PortFrom

To

Two nodes in a graph are called connected if there is a path between them.

Two nodes in a graph are called connected if there is a path between them.

Page 68: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

PortFrom

To

Two nodes in a graph are called connected if there is a path between them.

Two nodes in a graph are called connected if there is a path between them.

(These nodes are not connected. No Grand

Canyon for you.)

(These nodes are not connected. No Grand

Canyon for you.)

Page 69: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Two nodes in a graph are called connected if there is a path between them.

Two nodes in a graph are called connected if there is a path between them.

A graph G as a whole is called connected if all pairs of nodes in G are connected.

A graph G as a whole is called connected if all pairs of nodes in G are connected.

Page 70: Graph Theory - Stanford Universityweb.stanford.edu/class/cs103/lectures/10-GraphsI/GraphsI.1.pdf · An undirected graph is an ordered pair G = (V, E), where V is a set of nodes, which

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

A path in a graph G = (V, E) is a sequence of one or more nodes v₁, v₂, v₃, …, vₙ such that any two consecutive nodes in the sequence are adjacent.

Sea But

Mon

LV

SD Nog

SF

PhoeLA

FlagBar

Sac SLC

Port

Two nodes in a graph are called connected if there is a path between them.

Two nodes in a graph are called connected if there is a path between them.

A graph G as a whole is called connected if all pairs of nodes in G are connected.

A graph G as a whole is called connected if all pairs of nodes in G are connected.

(This graph is not connected.)

(This graph is not connected.)