Skip to content

Commit a667eaa

Browse files
committed
feat(Combinatorics/SimpleGraph/Connectivity): a graph is either connected or its complement is
1 parent a2df56f commit a667eaa

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Connectivity/Connected.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ theorem Iso.connected_iff {G : SimpleGraph V} {H : SimpleGraph V'} (e : G ≃g H
296296
G.Connected ↔ H.Connected :=
297297
⟨Connected.map e.toHom e.toEquiv.surjective, Connected.map e.symm.toHom e.symm.toEquiv.surjective⟩
298298

299+
theorem connected_or_compl_connected [Nonempty V] : G.Connected ∨ Gᶜ.Connected := by
300+
have ⟨v₀⟩ := ‹Nonempty V›
301+
by_cases hreach₀ : ∀ v, G.Reachable v₀ v
302+
· exact Or.inl <| G.connected_iff_exists_forall_reachable.mpr ⟨v₀, hreach₀⟩
303+
refine Or.inr <| Gᶜ.connected_iff_exists_forall_reachable.mpr ⟨v₀, fun v ↦ ?_⟩
304+
have ⟨v₁, hreach₁⟩ := not_forall.mp hreach₀
305+
have hcadj₁ : Gᶜ.Adj v₀ v₁ :=
306+
fun heq ↦ heq ▸ hreach₁ <| Reachable.refl _, mt Adj.reachable hreach₁⟩
307+
by_cases hreach : G.Reachable v₀ v
308+
· by_cases heq : v = v₁
309+
· exact heq ▸ Adj.reachable hcadj₁
310+
have : Gᶜ.Adj v v₁ := ⟨heq, fun hadj ↦ hreach₁ <| hreach.trans hadj.reachable⟩
311+
exact hcadj₁.reachable.trans this.reachable.symm
312+
by_cases heq : v₀ = v
313+
· exact heq ▸ Reachable.refl _
314+
exact Adj.reachable ⟨heq, mt Adj.reachable hreach⟩
315+
299316
/-- The quotient of `V` by the `SimpleGraph.Reachable` relation gives the connected
300317
components of a graph. -/
301318
def ConnectedComponent := Quot G.Reachable

0 commit comments

Comments
 (0)