Chapter 6Graphs and Treesnotes.en.pdf:90

Paths and Cycles

Walks, paths, when they loop

Def 6.2.1PathDef 6.2.2Cyclic path
Concept

A path is a sequence of vertices you can traverse by following edges. It is
how we talk about moving through a graph.

Definition 6.2.1 (notes p. 90): A path in G=V,EG = \langle V, E \rangle is an
(n+1)(n+1)-tuple

p=v0,v1,,vnVn+1p = \langle v_0, v_1, \dots, v_n \rangle \in V^{n+1}

such that (vi1,vi)E(v_{i-1}, v_i) \in E for every 1in1 \le i \le n, with n>0n > 0.

The vertex v0v_0 is the start and vnv_n is the end; the number nn is the
length of the path. Note: not all viv_i need to be different! When they are
distinct, the path is simple.

Three nested concepts:
- A walk allows repeated vertices and edges.
- A trail allows repeated vertices but distinct edges.
- A path has distinct vertices (and therefore distinct edges).

Definition 6.2.2 (notes p. 90): A path is cyclic (a cycle) if
start(p)=end(p)\text{start}(p) = \text{end}(p). A cycle is simple if no other vertex repeats.

Cycles cause real problems. Even a tiny cyclic graph can have paths of infinite
length — you just go around the cycle forever. This is why acyclic graphs are
often the focus in AI: parse trees, search trees, dependency graphs, causal graphs.

The length of a path matters: in a knowledge graph, a 1-hop path is a direct
relation; a 2-hop path is a relation-of-a-relation ("Paris", "capital-of", "France",
"speaks", "French"). The number of hops is a measure of how indirect the inference is.

Animation — euler tour
Transcript — click a line to jump9 cues
  1. 0.0sEuler tours and the Konigsberg bridges
  2. 1.3sFour vertices: left bank, right bank, islands A and B
  3. 2.5sSeven amber bridges draw between them
  4. 4.6sA violet walker starts at the left bank
  5. 5.2sWalker traverses bridges one by one, lighting them green
  6. 7.4sWalker gets stuck: stuck label appears in red
  7. 8.2sRed degree labels: LB 3, RB 3, A 5, B 3
  8. 9.8sAll odd-degree vertices — no Eulerian trail exists
  9. 11.0sThe original Konigsberg puzzle has no solution
Definition 2.5/2.6: Graph depth

Definition 2.5 (depth of a vertex). Let G=V,EG = \langle V, E \rangle be a directed graph. The depth of a vertex vv is the length of the longest directed path that starts at vv:

dp(v):=sup{len(p)p is a directed path starting at v}\text{dp}(v) := \sup \{ \text{len}(p) \mid p \text{ is a directed path starting at } v \}

If no path starts at vv (i.e. vv is a sink), dp(v)=0\text{dp}(v) = 0. If there are arbitrarily long paths starting at vv, dp(v)=\text{dp}(v) = \infty.

Definition 2.6 (depth of a graph). The depth of a graph is the supremum over all vertices:

dp(G):=supvVdp(v)\text{dp}(G) := \sup_{v \in V} \text{dp}(v)

Example 2.7. Consider the path graph v1v2v3v4v_1 \to v_2 \to v_3 \to v_4 \to \cdots with edges (vi,vi+1)(v_i, v_{i+1}):
- dp(v1)=\text{dp}(v_1) = \infty (we can walk forever to the right).
- dp(vn)=\text{dp}(v_n) = \infty for every nn — there is always a longer path to the right.
- dp(G)=\text{dp}(G) = \infty.

For a finite acyclic graph (DAG), every vertex has finite depth and dp(G)\text{dp}(G) is bounded by the length of the longest path.

Worked example
Step 0 of 3
Practice — score 100% to advance
Multiple choice
Q1
What is the length of the path v0,v1,v2\langle v_0, v_1, v_2 \rangle?
Q2
A cyclic path has…
Q3
In a simple path, vertices are…
Q4
Why are cyclic graphs problematic for path analysis?
Q5
A walk differs from a path in that a walk…
Q6
In a finite DAG, dp(G)\text{dp}(G) equals:
Fill in the blank
Q1
For a sink vertex (no outgoing edges), $\text{dp}(v) = ___.
Q2
Euler's theorem: a connected graph has an Eulerian circuit iff every vertex has ___ degree.
Order the steps
Arrange these proof steps in the correct order using the arrows.
1
End at vnv_n; report length =n= n
2
Verify each pair is an edge of the graph
3
Start with the start vertex v0v_0
4
Read each consecutive pair (vi1,vi)(v_{i-1}, v_i) as a step
Loading…