From 3cbdf41434ac33fea0bb4b3c501d72de06fae429 Mon Sep 17 00:00:00 2001 From: c-allergic <149845659+c-allergic@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:58:04 +0800 Subject: [PATCH] coloring document (#95) --- docs/make.jl | 1 + docs/src/models/Coloring.md | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 docs/src/models/Coloring.md diff --git a/docs/make.jl b/docs/make.jl index 4aeee4c..eae4e43 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -28,6 +28,7 @@ makedocs(; "Interfaces" => ["models.md", "topology.md", "rules.md"], "Models" => [ "models/CircuitSAT.md", + "models/Coloring.md", "models/Factoring.md", "models/SpinGlass.md" ], diff --git a/docs/src/models/Coloring.md b/docs/src/models/Coloring.md new file mode 100644 index 0000000..a7d9b66 --- /dev/null +++ b/docs/src/models/Coloring.md @@ -0,0 +1,26 @@ +# Vertex Coloring + +## Problem Definition +The Vertex Coloring (Coloring) problem is defined on a simple graph. Given k kinds of colors, we need to determine whether we can color all vertices on the graph such that no two adjacent vertices share the same color. +## Interfaces + +To initialize a [`Coloring`](@ref) problem, we need to first define a simple graph and decide the number of colors. + +```@repl Coloring +using ProblemReductions, Graphs +g = smallgraph(:petersen) # define a simple graph, petersen as example + +coloring = Coloring{3}(g) +``` +We create a petersen graph and take 3 colors here to initialize a Coloring Problem. + +Functions [`variables`](@ref), [`flavors`](@ref), [`num_flavors`](@ref), [`parameters`](@ref) and [`set_parameters`](@ref) are implemented for `Coloring` model. +```@repl Coloring +variables(coloring) +flavors(coloring) +``` + +Also, [`evaluate`](@ref) and [`is_vertex_coloring`](@ref) is also implemented. +```@repl Coloring +is_vertex_coloring(coloring.graph,[1,2,3,1,3,2,1,2,3,1]) #random assignment +``` \ No newline at end of file