我试图在 tex 中绘制以下“图形”(仿射平面):
我做了一些尝试并得到了当前的代码:
\documentclass[letterpaper]{article}
\usepackage{tikz}
\tikzset{
node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
every node/.style={circle,thin, fill=black}, % sets the properties for each ’state’ node
}
\begin{document}
\begin{tikzpicture}
\node[label = $1$] (1) {};
\node[label = $2$,right of=1] (2) {};
\node[label = $3$,right of=2] (3) {};
\node[label = $4$,below of=1] (4) {};
\node[label = $5$,below of=2] (5) {};
\node[label = $6$,below of=3] (6) {};
\node[label = $7$,below of=4] (7) {};
\node[label = $8$,below of=5] (8) {};
\node[label = $9$,below of=6] (9) {};
\draw[-]
(1) edge[green] (2)
(2) edge[green] (3)
(4) edge[red] (5)
(5) edge[red] (6)
(7) edge[purple] (8)
(8) edge[purple] (9)
(3) edge[yellow] (5)
(5) edge[yellow] (7)
(1) edge[gray] (5)
(5) edge[gray] (9)
(3) edge[blue] (6)
(6) edge[blue] (9)
(1) edge[cyan] (4)
(4) edge[cyan] (7)
(2) edge[pink] (5)
(5) edge[pink] (8)
(2) edge[dashed] (4)
(4) edge[dashed, bend right = 50, looseness = 2] (9);
\end{tikzpicture}
\end{document}
结果如下:
基本上,我很难弯曲边缘并正确定位标签。提前感谢任何帮助。
答案1
这是一个开始(使用不同的节点样式以避免穿过数字的线条)。
\documentclass{standalone}
\usepackage{tikz}
\tikzset{
node distance=3cm, % specifies the minimum distance between two nodes. Change if necessary.
every node/.style={circle,thin,draw=black}, % sets the properties for each ’state’ node
}
\begin{document}
\begin{tikzpicture}
\node(1) {$1$};
\node[right of=1] (2) {$2$};
\node[right of=2] (3) {$3$};
\node[below of=1] (4) {$4$};
\node[below of=2] (5) {$5$};
\node[below of=3] (6) {$6$};
\node[below of=4] (7) {$7$};
\node[below of=5] (8) {$8$};
\node[below of=6] (9) {$9$};
\draw[-]
(1) edge[green] (2)
(2) edge[green] (3)
(4) edge[red] (5)
(5) edge[red] (6)
(7) edge[purple] (8)
(8) edge[purple] (9)
(3) edge[yellow] (5)
(5) edge[yellow] (7)
(1) edge[gray] (5)
(5) edge[gray] (9)
(3) edge[blue] (6)
(6) edge[blue] (9)
(1) edge[cyan] (4)
(4) edge[cyan] (7)
(2) edge[pink] (5)
(5) edge[pink] (8)
(2) edge[dashed] (4)
(4) edge[dashed, out=225, in=225, looseness=2] (9);
\end{tikzpicture}
\end{document}