Documentation

CslibFrontier.Foundations.Combinatorics.Digraph.Branching

Branchings and out-arborescences #

A digraph B : Digraph V is a branching (Digraph.IsBranching) in the sense of Edmonds [Edmonds1967Branchings, Section 1] if every vertex has at most one incoming arc and there are no directed cycles (so B is a directed forest of disjoint out-arborescences, with arcs directed away from the roots). A spanning out-arborescence rooted at r (Digraph.IsOutArborescence) is a digraph whose reversal is a spanning in-arborescence rooted at r (Digraph.IsInArborescence).

To connect optimum branchings directly with rooted minimum-cost spanning in-arborescence algorithms, this module constructs the Option V super-root correspondence (Digraph.superRootExtend, Digraph.restrictOption): adjoining a super-root none with an arc some v → none for every vertex v without an incoming arc identifies the branchings B ≤ G with the spanning in-arborescences T ≤ Digraph.superRootDigraph G rooted at none (Digraph.isBranching_iff_isInArborescence_superRootExtend, Digraph.restrictOption_spec).

Main definitions #

Main results #

References #

Reversal and out-arborescences #

def Digraph.reverse {V : Type u_1} (G : Digraph V) :

The reversal of G, having an arc u → v iff G has v → u.

@[instance_reducible]
@[simp]
theorem Digraph.reverse_adj {V : Type u_1} {G : Digraph V} {u v : V} :
G.reverse.Adj u v ↔ G.Adj v u
@[simp]
theorem Digraph.reverse_reverse {V : Type u_1} (G : Digraph V) :
theorem Digraph.reverse_le_iff {V : Type u_1} {G H : Digraph V} :
@[reducible, inline]
abbrev Digraph.IsOutArborescence {V : Type u_1} (T : Digraph V) (r : V) :

T is a spanning out-arborescence rooted at r: an oriented spanning tree with every arc directed away from r (T.reverse.IsInArborescence r).

theorem Digraph.isOutArborescence_iff {V : Type u_1} {T : Digraph V} {r : V} :
T.IsOutArborescence r ↔ (∀ (u : V), ¬T.Adj u r) ∧ (∀ (v : V), v ≠ r → ∃! u : V, T.Adj u v) ∧ ∀ (v : V), Relation.ReflTransGen T.Adj r v
def Digraph.outParentDigraph {V : Type u_1} (r : V) (p : V → V) :

The out-arborescence digraph of a parent map p rooted at r: arcs p v → v for v ≠ r.

@[simp]
theorem Digraph.outParentDigraph_adj {V : Type u_1} {r : V} {p : V → V} {u v : V} :
(outParentDigraph r p).Adj u v ↔ v ≠ r ∧ p v = u
theorem Digraph.isOutArborescence_outParentDigraph_iff {V : Type u_1} {r : V} {p : V → V} :
(outParentDigraph r p).IsOutArborescence r ↔ ∀ (v : V), ∃ (n : ℕ), p^[n] v = r

outParentDigraph r p is a spanning out-arborescence rooted at r iff iterating p reaches r from every vertex.

theorem Digraph.IsOutArborescence.exists_outParentDigraph_eq {V : Type u_1} {T : Digraph V} {r : V} (hT : T.IsOutArborescence r) :
∃ (p : V → V), p r = r ∧ outParentDigraph r p = T

Every spanning out-arborescence rooted at r is outParentDigraph r p for some parent map p with p r = r.

Branchings #

structure Digraph.IsBranching {V : Type u_1} (B : Digraph V) :

A digraph B is a branching [Edmonds1967Branchings, Section 1] if each vertex has at most one incoming arc and B has no directed cycles.

  • in_unique ⦃u₁ u₂ v : V⦄ : B.Adj u₁ v → B.Adj u₂ v → u₁ = u₂

    Each vertex has at most one incoming arc.

  • acyclic ⦃v : V⦄ : ¬Relation.TransGen B.Adj v v

    B has no directed cycles (including self-loops).

theorem Digraph.IsBranching.loopless {V : Type u_1} {B : Digraph V} (hB : B.IsBranching) (v : V) :
¬B.Adj v v
theorem Digraph.IsBranching.no_two_cycle {V : Type u_1} {B : Digraph V} (hB : B.IsBranching) {u v : V} (huv : B.Adj u v) :
¬B.Adj v u
theorem Digraph.IsBranching.anti {V : Type u_1} {B B' : Digraph V} (hle : B' ≤ B) (hB : B.IsBranching) :
theorem Digraph.IsBranching.of_rank {V : Type u_1} {B : Digraph V} {rk : V → ℕ} (hrank : ∀ ⦃u w : V⦄, B.Adj u w → rk u < rk w) (hin : ∀ ⦃u₁ u₂ w : V⦄, B.Adj u₁ w → B.Adj u₂ w → u₁ = u₂) :

A digraph whose arcs strictly increase some ℕ-valued rank and give each vertex at most one incoming arc is a branching.

A spanning out-arborescence is a branching.

Parent-map representation of branchings #

def Digraph.branchingDigraph {V : Type u_1} (p : V → V) :

The digraph of a parent-towards-root map p: an arc p v → v whenever p v ≠ v. Vertices with p v = v are the roots of the branching's component out-arborescences.

@[simp]
theorem Digraph.branchingDigraph_adj {V : Type u_1} {p : V → V} {u v : V} :
(branchingDigraph p).Adj u v ↔ p v ≠ v ∧ p v = u
theorem Digraph.isBranching_branchingDigraph_of_reach_fixed {V : Type u_1} {p : V → V} (hfix : ∀ (v : V), ∃ (n : ℕ), p (p^[n] v) = p^[n] v) :

branchingDigraph p is a branching when iterating p from every vertex reaches a fixed point (root). On finite vertex types the converse also holds.

theorem Digraph.isBranching_branchingDigraph_iff {V : Type u_1} [Finite V] {p : V → V} :
(branchingDigraph p).IsBranching ↔ ∀ (v : V), ∃ (n : ℕ), p (p^[n] v) = p^[n] v

On a finite vertex type, branchingDigraph p is a branching iff iterating p reaches a fixed point from every vertex.

theorem Digraph.IsBranching.exists_branchingDigraph_eq {V : Type u_1} {B : Digraph V} (hB : B.IsBranching) :
∃ (p : V → V), (∀ (v : V), p v = v ↔ ¬∃ (u : V), B.Adj u v) ∧ branchingDigraph p = B

Every branching is branchingDigraph p for a parent-towards-root map p fixing every vertex with no incoming arc.

theorem Digraph.IsBranching.exists_rank {V : Type u_1} [Finite V] {B : Digraph V} (hB : B.IsBranching) :
∃ (rk : V → ℕ), ∀ ⦃u w : V⦄, B.Adj u w → rk u < rk w

Every branching on a finite vertex type admits a strict root-distance ranking rk : V → ℕ that increases along every arc.

Super-root bijection on Option V #

The super-root augmentation of G on Option V: real arcs of G are reversed (some v → some u iff G.Adj u v), and every vertex some v also has a rootward arc to none.

@[simp]
theorem Digraph.superRootDigraph_some_some {V : Type u_1} (G : Digraph V) (u v : V) :
@[simp]
@[simp]

Extend a subdigraph B : Digraph V to Option V by sending every vertex without an incoming arc in B to none, and reversing existing arcs of B.

@[simp]
theorem Digraph.superRootExtend_some_some {V : Type u_1} (B : Digraph V) (u v : V) :
@[simp]
theorem Digraph.superRootExtend_some_none {V : Type u_1} (B : Digraph V) (v : V) :
B.superRootExtend.Adj (some v) none ↔ ¬∃ (u : V), B.Adj u v
@[simp]
def Digraph.restrictOption {V : Type u_1} (T : Digraph (Option V)) :

Restrict an Option V digraph back to V by forgetting none and reversing real arcs.

@[simp]
theorem Digraph.restrictOption_adj {V : Type u_1} (T : Digraph (Option V)) (u v : V) :
T.restrictOption.Adj u v ↔ T.Adj (some v) (some u)

For a finite vertex type, a digraph B is a branching iff its super-root extension on Option V is a spanning in-arborescence rooted at none.

Every spanning in-arborescence T on Option V rooted at none restricts to a branching on V whose super-root extension equals T, and T ≤ superRootDigraph G iff the branching lies in G.

Arc counts, spanning out-arborescences, and undirected forests #

theorem Digraph.IsBranching.exists_not_adj_into {V : Type u_1} [Finite V] [Nonempty V] {B : Digraph V} (hB : B.IsBranching) :
∃ (r : V), ∀ (u : V), ¬B.Adj u r

A finite nonempty branching has at least one root (a vertex with no incoming arc).

theorem Digraph.IsBranching.card_arcs_add_card_roots {V : Type u_1} [Fintype V] {B : Digraph V} [DecidableRel B.Adj] (hB : B.IsBranching) :
{e : V × V | B.Adj e.1 e.2}.card + {v : V | ¬∃ (u : V), B.Adj u v}.card = Fintype.card V

Every vertex without an incoming arc in a branching is a root; the number of arcs plus the number of roots equals the number of vertices.

theorem Digraph.IsBranching.card_arcs_le {V : Type u_1} [Fintype V] {B : Digraph V} [DecidableRel B.Adj] (hB : B.IsBranching) :
{e : V × V | B.Adj e.1 e.2}.card ≤ Fintype.card V - 1

Edmonds (1967, Section 1): No branching on n vertices has more than n - 1 arcs.

theorem Digraph.IsBranching.isOutArborescence_iff_card_arcs {V : Type u_1} [Fintype V] [Nonempty V] {B : Digraph V} [DecidableRel B.Adj] (hB : B.IsBranching) :
(∃ (r : V), B.IsOutArborescence r) ↔ {e : V × V | B.Adj e.1 e.2}.card = Fintype.card V - 1

Edmonds (1967, Section 1): A branching on n ≥ 1 vertices is a spanning out-arborescence iff it has n - 1 arcs.

Acyclicity of the underlying undirected simple graph #

Edmonds (1967, Section 1): Every branching has an acyclic underlying undirected simple graph (forest).