Skip to content

Commit 848cd9b

Browse files
feat: add vertex connectivity foundations
1 parent 2131653 commit 848cd9b

1 file changed

Lines changed: 155 additions & 0 deletions

File tree

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/-
2+
Copyright (c) 2025 Youheng Luo. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Youheng Luo
5+
-/
6+
module
7+
public import Mathlib.Combinatorics.SimpleGraph.Connectivity.Connected
8+
public import Mathlib.Data.Set.Card
9+
10+
/-!
11+
# Vertex Connectivity
12+
13+
This file defines k-vertex connectivity for simple graphs.
14+
15+
## Main definitions
16+
17+
* `SimpleGraph.IsVertexReachable`: Two vertices are `k`-vertex-reachable if they remain reachable
18+
after removing strictly fewer than `k` other vertices.
19+
* `SimpleGraph.IsVertexConnected`: A graph is `k`-vertex-connected if it has more than `k`
20+
vertices and any two vertices are `k`-vertex-reachable.
21+
-/
22+
23+
@[expose] public section
24+
25+
namespace SimpleGraph
26+
27+
variable {V : Type*} {G H : SimpleGraph V} {k l : ℕ∞} {u v : V}
28+
29+
/-- `G.isolateVerts s` is the graph where all vertices in `s` are isolated. -/
30+
def isolateVerts (G : SimpleGraph V) (s : Set V) : SimpleGraph V where
31+
Adj u v := u ∉ s ∧ v ∉ s ∧ G.Adj u v
32+
symm _ _ h := ⟨h.2.1, h.1, h.2.2.symm⟩
33+
34+
@[simp]
35+
lemma isolateVerts_empty : G.isolateVerts ∅ = G := by
36+
ext; simp [isolateVerts]
37+
38+
@[simp]
39+
lemma isolateVerts_bot (s : Set V) : (⊥ : SimpleGraph V).isolateVerts s = ⊥ := by
40+
ext; simp [isolateVerts]
41+
42+
@[simp]
43+
lemma isolateVerts_le (s : Set V) : G.isolateVerts s ≤ G :=
44+
fun _ _ h ↦ h.2.2
45+
46+
variable (G k u v) in
47+
/-- Two vertices are `k`-vertex-reachable if they remain reachable after removing
48+
strictly fewer than `k` other vertices. -/
49+
def IsVertexReachable : Prop :=
50+
∀ ⦃s : Set V⦄, s.encard < k → u ∉ s → v ∉ s → (G.isolateVerts s).Reachable u v
51+
52+
@[simp]
53+
lemma IsVertexReachable.refl (u : V) : G.IsVertexReachable k u u :=
54+
fun _ _ _ _ ↦ .refl _
55+
56+
@[symm]
57+
lemma IsVertexReachable.symm (h : G.IsVertexReachable k u v) : G.IsVertexReachable k v u :=
58+
fun _ hs hv hu ↦ (h hs hu hv).symm
59+
60+
lemma isVertexReachable_symm : G.IsVertexReachable k u v ↔ G.IsVertexReachable k v u :=
61+
⟨.symm, .symm⟩
62+
63+
@[gcongr]
64+
lemma IsVertexReachable.mono (hGH : G ≤ H) (h : G.IsVertexReachable k u v) :
65+
H.IsVertexReachable k u v :=
66+
fun _ hs hu hv ↦ (h hs hu hv).mono (by intro _ _ ⟨h1, h2, h3⟩; exact ⟨h1, h2, hGH h3⟩)
67+
68+
@[gcongr]
69+
lemma IsVertexReachable.anti (hkl : k ≤ l) (h : G.IsVertexReachable l u v) :
70+
G.IsVertexReachable k u v :=
71+
fun _ hs ↦ h (hs.trans_le hkl)
72+
73+
@[simp]
74+
lemma IsVertexReachable.zero : G.IsVertexReachable 0 u v :=
75+
fun _ hs ↦ absurd hs not_lt_zero
76+
77+
lemma IsVertexReachable.of_adj (h : G.Adj u v) (k : ℕ∞) : G.IsVertexReachable k u v :=
78+
fun _ _ hu hv ↦ (Adj.reachable ⟨hu, hv, h⟩)
79+
80+
alias _root_.SimpleGraph.Adj.isVertexReachable := IsVertexReachable.of_adj
81+
82+
/-- A vertex pair is reachable if it is `k`-vertex-reachable for `k ≠ 0`. -/
83+
lemma IsVertexReachable.reachable (hk : k ≠ 0) (h : G.IsVertexReachable k u v) :
84+
G.Reachable u v := by
85+
rw [← G.isolateVerts_empty]
86+
apply h <;> simp [pos_of_ne_zero hk]
87+
88+
variable (G) (k : ℕ∞) in
89+
/-- A graph is `k`-vertex-connected if it has more than `k` vertices
90+
and any two vertices are `k`-vertex-reachable. -/
91+
def IsVertexConnected : Prop :=
92+
k + 1 ≤ ENat.card V ∧ ∀ u v : V, G.IsVertexReachable k u v
93+
94+
@[simp]
95+
lemma isVertexConnected_zero : G.IsVertexConnected 0 ↔ Nonempty V := by
96+
rw [IsVertexConnected]
97+
have h0 : (0 : ℕ∞) + 1 = 1 := rfl
98+
rw [h0]
99+
simp [ENat.one_le_card_iff_nonempty]
100+
101+
/-- 1-vertex-connectivity is equivalent to being a connected graph with at least 2 vertices. -/
102+
lemma isVertexConnected_one :
103+
G.IsVertexConnected 12 ≤ ENat.card V ∧ G.Connected := by
104+
rw [IsVertexConnected]
105+
have h1 : (1 : ℕ∞) + 1 = 2 := rfl
106+
rw [h1]
107+
constructor
108+
· rintro ⟨h_card, h_reach⟩
109+
refine ⟨h_card, ?_⟩
110+
rw [connected_iff_exists_forall_reachable]
111+
have h_ne : Nonempty V := by
112+
rw [← ENat.one_le_card_iff_nonempty]
113+
exact (self_le_add_right (1 : ℕ∞) 1).trans h_card
114+
rcases h_ne with ⟨x⟩
115+
refine ⟨x, fun y ↦ (h_reach x y).reachable (by simp)⟩
116+
· rintro ⟨h_card, h_conn⟩
117+
refine ⟨h_card, fun u v s hs _ _ ↦ ?_⟩
118+
have : s = ∅ := by
119+
rw [← Set.encard_eq_zero, ← ENat.lt_one_iff_eq_zero]
120+
exact hs
121+
subst this
122+
rw [isolateVerts_empty]
123+
exact h_conn.preconnected u v
124+
125+
/-- Vertex connectivity is antitonic in `k`. -/
126+
lemma IsVertexConnected.anti {k l : ℕ∞} (hkl : l ≤ k) (hc : G.IsVertexConnected k) :
127+
G.IsVertexConnected l := by
128+
constructor
129+
· let h_le := add_le_add_right hkl 1
130+
let h_card := hc.1
131+
have h1 : l + 1 = 1 + l := add_comm ..
132+
have h2 : k + 1 = 1 + k := add_comm ..
133+
rw [h1]
134+
rw [h2] at h_card
135+
exact h_le.trans h_card
136+
· exact fun u v ↦ (hc.2 u v).anti hkl
137+
138+
/-- Vertex connectivity is monotonic in the graph. -/
139+
lemma IsVertexConnected.mono {k : ℕ∞} (hGH : G ≤ H) (hc : G.IsVertexConnected k) :
140+
H.IsVertexConnected k :=
141+
⟨hc.1, fun u v ↦ (hc.2 u v).mono hGH⟩
142+
143+
/-- The complete graph on `n` vertices is `(n-1)`-vertex-connected. -/
144+
lemma isVertexConnected_top [Fintype V] [Nonempty V] :
145+
(⊤ : SimpleGraph V).IsVertexConnected (Fintype.card V - 1) := by
146+
constructor
147+
· rw [ENat.card_eq_coe_fintype_card]
148+
norm_cast
149+
exact Nat.sub_add_cancel Fintype.card_pos |>.le
150+
· intro u v
151+
by_cases h : u = v
152+
· subst h; exact .refl _
153+
· exact IsVertexReachable.of_adj h _
154+
155+
end SimpleGraph

0 commit comments

Comments
 (0)