diff --git a/docs/draft.docx b/docs/draft.docx new file mode 100644 index 0000000..1efef8b Binary files /dev/null and b/docs/draft.docx differ diff --git a/docs/draft.pdf b/docs/draft.pdf new file mode 100644 index 0000000..758a227 Binary files /dev/null and b/docs/draft.pdf differ diff --git a/draft.html b/draft.html deleted file mode 100644 index c44ca28..0000000 --- a/draft.html +++ /dev/null @@ -1,211 +0,0 @@ - - draft - - - - - - - - - - - - - -
- -

Title

-题目 -

对于图C1:

-

- - - - - -C1 - - - -1 - -1 - - - -2 - -2 - - - -1--2 - - - - -4 - -4 - - - -1--4 - - - - -3 - -3 - - - -2--3 - - - - -5 - -5 - - - -2--5 - - - - -4--5 - - - - -6 - -6 - - - -4--6 - - - - -3--6 - - - - -5--6 - - - - -

考虑其独立集C2:

-

- - - - - -C2 - - - -1 - -1 - - - -3 - -3 - - - -1--3 - - - - -5 - -5 - - - -1--5 - - - - -6 - -6 - - - -1--6 - - - - -3--5 - - - - -4 - -4 - - - -3--4 - - - - -2 - -2 - - - -2--6 - - - - -2--4 - - - - -

-
- - - - - - - - - - \ No newline at end of file diff --git a/draft.md b/draft.md index 13a275a..816340a 100644 --- a/draft.md +++ b/draft.md @@ -12,28 +12,56 @@ #### 常规思路 -首先,D、E、F三个区域有$A_4^3 = 144$种涂法。\ -当B、F区域同色时,有$A_4^3*2*3 = 144$种涂法。\ -当B、D、F均不同色时,有$A_4^3 = 96$种涂法。\ -故总方案数为$144 + 144 + 96 = 384$种涂法。 - -这是在基于观察对区域进行分类,在面对复杂的图像时难免会存在遗漏。 +首先,D、E、F三个区域有 $A_4^3 = 144$ 种涂法。\ +当B、F区域同色时,有 $A_4^3 \times 2 \times 3 = 144$ 种涂法。\ +当B、D、F均不同色时,有 $A_4^3 = 96$ 种涂法。\ +故总方案数为 $144 + 144 + 96 = 384$ 种涂法。 #### 基于独立集的思路 -可将A~F抽象为图中的节点,用边连接具有公共边的色块对应的节点,形成图C1: +##### 理论 + +可将A~F抽象为图中的节点,用边连接具有公共边的色块对应的节点,形成图$C_1$: C1 -考虑其独立集[^1] C2: +考虑其独立集[^1] $C_2$: C2 -此时,C2中的边所连接的节点对应的,就是“一对不具有公共边的色块”,也就是一对可以被涂上同种颜色的色块。\ -那么,C2中的任意团[^2]都对应着“一些可以被涂上同种颜色的色块”。 -如果能将图分解为不同的 +此时,$C_2$中的边所连接的节点对应的,就是“一对不具有公共边的色块”,也就是一对可以被涂上同种颜色的色块。\ +那么,$C_2$中的任意团[^2]都对应着“一些可以被涂上同种颜色的色块”。如果能将$C_2$完全分割为$i$个团,则原图可以被$i$种颜色涂色,也就实现了“将原图分为$i$组”的操作。 +再将$m$种颜色分配给$i$个团,方案数为$A_m^i$。 -由于对任意节点,其参与形成的不同的团 +若将$C_2$拆分为$i$个团的方案数为$n_i$,提供的最大颜色数为$m$,总染色方案数为$N$,有: + +$$N = \sum_{i = 1}^{m}({n_i}{A_m^i})$$ + +##### 实现 + +由于对任意节点,其参与形成的不同的团不会处于同一分割方式中,可递归地对图进行分割。 + +如,$A$ 节点可形成 $\{\{A\},\emptyset\}$,$\{\{A,C\},{(A,C)}\}$,$\{\{A,E\},(A,E)\}$,$\{\{A,F\},(A,F)\}$,$\{\{A,C,E\},\{(A,C),(A,E),(C,E)\}\}$ 几个团。\ +以分割 $\{\{A\},\emptyset\}$ 为例: + +C3_2 + +此时,除$\{\{A\},\emptyset\}$以外的部分形成了一张新的子图$C_3$ +当然,对于$C_3$,同样可以继续选择节点进行分割并讨论,但这显然太复杂了。对于计算机,仅有几个节点的情况尚可以借助递归轻松完成统计;但对于人脑,这种费时费力的方法反而会增大出错的概率。 + +因此,对其进行优化是有必要的。 + +##### 一种优化思路 + +定义 $f(i,k)$ 为“将路径图[^3] $P_k$ 分割为$i$个团的方案数"。考虑到路径图的团至多有2个节点,至少有1个节点, $f(i,k) \neq 0$ 时有 $i \in [ {\lceil \frac{k}{2} \rceil},k ]$ 。 +显然有 $f(k,k) = 1$ 。 +若将任意两相邻节点合并为新的团,则有 $C_{k-1}^1 = k-1$ 种方案,即 $f(k-1,k) = k-1$ 。 +对于一般的路径图,可以在端点处递归分割,即 $f(i,k) = f(i-1,k-1) + f(i-1,k-2)$ 。 + +回到例题,显然$C_3$属于路径图 $P_5$ , $\{\{A\},\emptyset\}$ 本身也是一个团,因此由题有 $i \in [2,3]$,$f(2,5) = 0$ , $f(3,5) = f(2,4) + f(2,3) = 3$ 。 + +用相同方法处理剩下四种情况,即可得 $N = A_4^3 \times (0+0+1+1+2) + A_4^4 \times (3+2+3+3+1) = 384$ [^1]: 独立集:一个图中两两不相邻的顶点所形成的集合,见《图论导论》。 [^2]: 团:图的“任意两个顶点在图中相邻”的子集,见《图论导论》。 +[^3]: 路径图:链状的图,通常用$P_n$表示含$n$个节点的路径图。 diff --git a/draft.pdf b/draft.pdf deleted file mode 100644 index c5e2fb5..0000000 Binary files a/draft.pdf and /dev/null differ diff --git a/generate_maps.sh b/generate_maps.sh index 49bb8fc..0606da7 100644 --- a/generate_maps.sh +++ b/generate_maps.sh @@ -1,3 +1,6 @@ for file in srcs/*.dot; do dot -Tsvg "$file" -o "svgs/$(basename "${file%.dot}").svg" -done \ No newline at end of file +done + +pandoc -N -s --toc -f markdown+smart --pdf-engine=xelatex draft.md -o docs/draft.pdf +pandoc draft.md -o docs/draft.docx \ No newline at end of file diff --git a/srcs/C3_1.dot b/srcs/C3_1.dot new file mode 100644 index 0000000..b36f244 --- /dev/null +++ b/srcs/C3_1.dot @@ -0,0 +1,22 @@ +graph C3_1{ + graph [ + layout=neato, + overlap=false, + splines=true, + ]; + + node [ + shape=circle, + style=filled, + fillcolor="grey", + width=0.4, height=0.4, fixedsize=true, + ]; + + edge [ + color="gray", + penwidth=5.5, + len=1; + ]; + B -- D,F; + C -- D,E; +} \ No newline at end of file diff --git a/srcs/C3_2.dot b/srcs/C3_2.dot new file mode 100644 index 0000000..b6c77f6 --- /dev/null +++ b/srcs/C3_2.dot @@ -0,0 +1,22 @@ +graph C3_2{ + graph [ + layout=neato, + overlap=false, + splines=true, + ]; + + node [ + shape=circle, + style=filled, + fillcolor="grey", + width=0.4, height=0.4, fixedsize=true, + ]; + + edge [ + color="gray", + penwidth=5.5, + len=1; + ]; + B -- D,F; + E; +} \ No newline at end of file diff --git a/srcs/C3_3.dot b/srcs/C3_3.dot new file mode 100644 index 0000000..9946217 --- /dev/null +++ b/srcs/C3_3.dot @@ -0,0 +1,22 @@ +graph C3_3{ + graph [ + layout=neato, + overlap=false, + splines=true, + ]; + + node [ + shape=circle, + style=filled, + fillcolor="grey", + width=0.4, height=0.4, fixedsize=true, + ]; + + edge [ + color="gray", + penwidth=5.5, + len=1; + ]; + B -- D,F; + C -- D; +} \ No newline at end of file diff --git a/srcs/C3_4.dot b/srcs/C3_4.dot new file mode 100644 index 0000000..390c140 --- /dev/null +++ b/srcs/C3_4.dot @@ -0,0 +1,22 @@ +graph C3_4{ + graph [ + layout=neato, + overlap=false, + splines=true, + ]; + + node [ + shape=circle, + style=filled, + fillcolor="grey", + width=0.4, height=0.4, fixedsize=true, + ]; + + edge [ + color="gray", + penwidth=5.5, + len=1; + ]; + B -- D; + C -- D,E; +} \ No newline at end of file diff --git a/srcs/C3_5.dot b/srcs/C3_5.dot new file mode 100644 index 0000000..3c7af28 --- /dev/null +++ b/srcs/C3_5.dot @@ -0,0 +1,21 @@ +graph C3_5{ + graph [ + layout=neato, + overlap=false, + splines=true, + ]; + + node [ + shape=circle, + style=filled, + fillcolor="grey", + width=0.4, height=0.4, fixedsize=true, + ]; + + edge [ + color="gray", + penwidth=5.5, + len=1; + ]; + B -- D,F; +} \ No newline at end of file diff --git a/svgs/C3_1.svg b/svgs/C3_1.svg new file mode 100644 index 0000000..106f960 --- /dev/null +++ b/svgs/C3_1.svg @@ -0,0 +1,63 @@ + + + + + + +C3_1 + + + +B + +B + + + +D + +D + + + +B--D + + + + +F + +F + + + +B--F + + + + +C + +C + + + +C--D + + + + +E + +E + + + +C--E + + + + diff --git a/svgs/C3_2.svg b/svgs/C3_2.svg new file mode 100644 index 0000000..9460c91 --- /dev/null +++ b/svgs/C3_2.svg @@ -0,0 +1,47 @@ + + + + + + +C3_2 + + + +B + +B + + + +D + +D + + + +B--D + + + + +F + +F + + + +B--F + + + + +E + +E + + + diff --git a/svgs/C3_3.svg b/svgs/C3_3.svg new file mode 100644 index 0000000..c8080be --- /dev/null +++ b/svgs/C3_3.svg @@ -0,0 +1,52 @@ + + + + + + +C3_3 + + + +B + +B + + + +D + +D + + + +B--D + + + + +F + +F + + + +B--F + + + + +C + +C + + + +C--D + + + + diff --git a/svgs/C3_4.svg b/svgs/C3_4.svg new file mode 100644 index 0000000..23b2de6 --- /dev/null +++ b/svgs/C3_4.svg @@ -0,0 +1,52 @@ + + + + + + +C3_4 + + + +B + +B + + + +D + +D + + + +B--D + + + + +C + +C + + + +C--D + + + + +E + +E + + + +C--E + + + + diff --git a/svgs/C3_5.svg b/svgs/C3_5.svg new file mode 100644 index 0000000..f927397 --- /dev/null +++ b/svgs/C3_5.svg @@ -0,0 +1,41 @@ + + + + + + +C3_5 + + + +B + +B + + + +D + +D + + + +B--D + + + + +F + +F + + + +B--F + + + +