graph theory - stanford universityweb.stanford.edu/class/cs103/lectures/10-graphsi/graphsi.1.pdf ·...
TRANSCRIPT
Graph TheoryPart One
Graph TheoryPart One
For those of you who have already
completed CS106B/X:
http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg
Chemical Bonds
http://4.bp.blogspot.com/-xCtBJ8lKHqA/Tjm0BONWBRI/AAAAAAAAAK4/-mHrbAUOHHg/s1600/Ethanol2.gif
http://www.prospectmagazine.co.uk/wp-content/uploads/2009/09/163_taylor2.jpg
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.
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes connected by edges.
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes (or vertices) connected by edges (or arcs)
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes (or vertices) connected by edges (or arcs)
Nodes
A graph is a mathematical structurefor representing relationships.
A graph consists of a set of nodes (or vertices) connected by edges (or arcs)
Edges
Some graphs are directed.
On these sites, you can follow someone who doesn’t follow
you back.
A tournament diagram shows who
beat who.
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.
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).
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?
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.
● 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
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.
✓×
Standard Graph Terminology
CAT SAT RAT
RANMAN
MAT
CAN
Two nodes are called adjacent if there is an edge between them.
CAT SAT RAT
RANMAN
MAT
CAN
Two nodes are called adjacent if there is an edge between them.
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.
http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg
http://strangemaps.files.wordpress.com/2007/02/fullinterstatemap-web.jpg
SF Sac
Port
Sea But
SLC
Mon
LV
Bar Flag
LA
SD Nog
Phoe
SF Sac
Port
Sea But
SLC
Mon
LV
Bar Flag
LA
SD Nog
Phoe
From
To
SLC
LA
SD
But
Mon
LV
Bar Flag
Nog
Phoe
SF Sac
Port
Sea
From
To
SF, Sac, Port, SeaSF, Sac, Port, Sea
LA
SD
But
Mon
LV
Bar Flag
Nog
Phoe
SLCSF Sac
Port
Sea
From
To
SF, Sac, SLC, Port, SeaSF, Sac, SLC, Port, Sea
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
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
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
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.)
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.
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
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
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
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
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.
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.
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
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
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
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
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
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
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
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
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 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.)
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.)
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
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
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
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
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
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
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
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
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 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.)
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.)
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
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
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
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
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
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.
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.)
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.
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.)