Bipartite graphs and bipartite complements
Lax185574.BipartiteGraphs · concepts/Lax185574/BipartiteGraphs.lean · lax-185574
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A bipartite graph B = (X, Y, E) has parts X and Y and an edge set E of pairs xy with x ∈ X and y ∈ Y. Its bipartite complement, denoted B̄, is the bipartite graph with parts X, Y and edge set XY ∖ E.
For a graph G and disjoint vertex sets X, Y ⊆ V(G), G[X, Y] is the bipartite graph with parts X and Y whose edges connect pairs of vertices that are adjacent in G. Furthermore, G[X, X] denotes the bipartite graph whose parts are two copies of X, and whose edges connect two vertices in opposite parts if the corresponding vertices of G are either adjacent or equal. The edges of G[X, X] connecting the two copies of a vertex are its diagonal edges. Finally, Ḡ[X, X] is the bipartite complement of G[X, X], extended with the diagonal edges.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.Combinatorics.SimpleGraph.Basic |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Bipartite graphs and bipartite complements |
| 6 | type: definition |
| 7 | --- |
| 8 | A *bipartite graph* B = (X, Y, E) has parts X and Y and an edge set E |
| 9 | of pairs xy with x ∈ X and y ∈ Y. Its *bipartite complement*, denoted |
| 10 | B̄, is the bipartite graph with parts X, Y and edge set XY ∖ E. |
| 11 | |
| 12 | For a graph G and disjoint vertex sets X, Y ⊆ V(G), G[X, Y] is the |
| 13 | bipartite graph with parts X and Y whose edges connect pairs of vertices |
| 14 | that are adjacent in G. Furthermore, G[X, X] denotes the bipartite |
| 15 | graph whose parts are two copies of X, and whose edges connect two |
| 16 | vertices in opposite parts if the corresponding vertices of G are |
| 17 | either adjacent or equal. The edges of G[X, X] connecting the two copies |
| 18 | of a vertex are its *diagonal edges*. Finally, Ḡ[X, X] is the bipartite |
| 19 | complement of G[X, X], extended with the diagonal edges. |
| 20 | |
| 21 | # Formalization notes |
| 22 | |
| 23 | A bipartite graph with parts α and β is given by a relation |
| 24 | E : α → β → Prop, and `bipartiteGraph E` is the simple graph on α ⊕ β |
| 25 | that it defines. The bipartite complement is `bipartiteGraph` of the |
| 26 | negated relation. |
| 27 | |
| 28 | The graphs G[X, Y] and Ḡ[X, Y] are built uniformly on two copies of the |
| 29 | vertex set, V ⊕ V, as `pairGraph` and `coPairGraph`. The left copy of |
| 30 | X is one part and the right copy of Y is the other. A left vertex u ∈ X |
| 31 | and a right vertex v ∈ Y are adjacent if u = v or u and v are adjacent |
| 32 | in G, respectively non-adjacent in G. For X = Y this is G[X, X], with |
| 33 | its diagonal edges, and Ḡ[X, X]. For disjoint X and Y the case u = v |
| 34 | never occurs, so this is G[X, Y], and Ḡ[X, Y] is its bipartite |
| 35 | complement, the bipartite graph of the non-adjacent pairs. The other |
| 36 | vertices of V ⊕ V are isolated. So the distance from the left copy of u |
| 37 | to the right copy of v in `pairGraph G X Y` is the distance between u |
| 38 | and v in G[X, Y], and likewise for Ḡ[X, Y]. |
| 39 | -/ |
| 40 | |
| 41 | namespace Lax185574.BipartiteGraphs |
| 42 | |
| 43 | universe u w z |
| 44 | |
| 45 | /-- The bipartite graph on `α ⊕ β` with an edge between `inl a` and |
| 46 | `inr b` exactly when `E a b`. -/ |
| 47 | def bipartiteGraph {α : Type u} {β : Type w} (E : α → β → Prop) : SimpleGraph (α ⊕ β) := |
| 48 | SimpleGraph.fromRel fun s t => ∃ a b, s = .inl a ∧ t = .inr b ∧ E a b |
| 49 | |
| 50 | variable {V : Type z} |
| 51 | |
| 52 | /-- `G[X, Y]`, on two copies of `V`: the left copy of `u ∈ X` and the |
| 53 | right copy of `v ∈ Y` are adjacent if `u = v` or `u` and `v` are |
| 54 | adjacent in `G`. -/ |
| 55 | def pairGraph (G : SimpleGraph V) (X Y : Set V) : SimpleGraph (V ⊕ V) := |
| 56 | bipartiteGraph fun u v => u ∈ X ∧ v ∈ Y ∧ (u = v ∨ G.Adj u v) |
| 57 | |
| 58 | /-- `Ḡ[X, Y]`, on two copies of `V`: the left copy of `u ∈ X` and the |
| 59 | right copy of `v ∈ Y` are adjacent if `u = v` or `u` and `v` are |
| 60 | non-adjacent in `G`. -/ |
| 61 | def coPairGraph (G : SimpleGraph V) (X Y : Set V) : SimpleGraph (V ⊕ V) := |
| 62 | bipartiteGraph fun u v => u ∈ X ∧ v ∈ Y ∧ (u = v ∨ ¬ G.Adj u v) |
| 63 | |
| 64 | end Lax185574.BipartiteGraphs |
| 65 |
Formalization notes
A bipartite graph with parts α and β is given by a relation E : α → β → Prop, and is the simple graph on α ⊕ β that it defines. The bipartite complement is of the negated relation.
The graphs G[X, Y] and Ḡ[X, Y] are built uniformly on two copies of the vertex set, V ⊕ V, as and . The left copy of X is one part and the right copy of Y is the other. A left vertex u ∈ X and a right vertex v ∈ Y are adjacent if u = v or u and v are adjacent in G, respectively non-adjacent in G. For X = Y this is G[X, X], with its diagonal edges, and Ḡ[X, X]. For disjoint X and Y the case u = v never occurs, so this is G[X, Y], and Ḡ[X, Y] is its bipartite complement, the bipartite graph of the non-adjacent pairs. The other vertices of V ⊕ V are isolated. So the distance from the left copy of u to the right copy of v in is the distance between u and v in G[X, Y], and likewise for Ḡ[X, Y].
Builds on
none
From Mathlib
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments