答案1
这是不是您的图表,但我推荐它的变体。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[every node/.style={circle,minimum size=.75cm,draw}]
\node (a) at (0,2) {Goal};
\node (c2) at (0,0) {$c_2$};
\node (c3) at (2,0) {$c_3$};
\node (c1) at (-2,0) {$c_1$};
\node (a1) at (-1,-2) {$a_1$};
\node (a2) at (1,-2) {$a_2$};
\end{scope}
\draw (a)--(c1)--(a1)--(c2)--(a2)--(c3)--(a)--(c2) (c1)--(a2) (c3)--(a1);
\end{tikzpicture}
\end{document}
一些说明:
答案2
基于铅笔画,这里有一个示例代码,您可以根据需要改进它:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{squarenode/.style = {
shape = rectangle,
draw = black,
minimum height = 2cm,
minimum width = 2cm
}}
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (a) at (0,0) [squarenode] {Goal};
\node[below=of a] (c2) [squarenode] {C2};
\node[left=of c2] (c1) [squarenode] {C1};
\node[right=of c2] (c3) [squarenode] {C3};
\node[below=of c1] (a1) [squarenode] {A1};
\node[below=of c2] (a2) [squarenode] {A2};
\draw (a.south) to (c1.north);
\draw (a.south) to (c2.north);
\draw (a.south) to (c3.north);
\draw (c1.south) to (a1.north);
\draw (c1.south) to (a2.north west);
\draw (c2.south) to (a2.north);
\draw (c2.south) to (a1.north east);
\draw (c3.south) to (a1.north);
\draw (c3.south) to (a2.north);
\end{tikzpicture}
\end{document}
要了解使用的锚点,请参考下面的图表和代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{dot/.style = {
shape = circle,
draw = black,
fill = black,
minimum size = 0.2cm
}}
\tikzset{squarenode/.style = {
shape = rectangle,
draw = black,
minimum height = 10cm,
minimum width = 10cm
}}
\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (a) at (0,0) [squarenode] {};
\node[label=a.center] at (a.center) [dot] {};
\node[label=a.north] at (a.north) [dot] {};
\node[label=a.south] at (a.south) [dot] {};
\node[label=a.east] at (a.east) [dot] {};
\node[label=a.west] at (a.west) [dot] {};
\node[label=a.north east] at (a.north east) [dot] {};
\node[label=a.north west] at (a.north west) [dot] {};
\node[label=a.south east] at (a.south east) [dot] {};
\node[label=a.south west] at (a.south west) [dot] {};
\end{tikzpicture}
\end{document}
答案3
我认为这是 TikZ 矩阵的工作。
您<matrix-name>-<row-number>-<column-number>
可以将矩阵单元称为节点。
这里有两版图表,如果您希望节点为平方,请省略该circle
选项:
\documentclass{book}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
\tikzset{
mymatrix/.style={
matrix of math nodes,
nodes={draw, circle},
row sep=10ex,
}
}
\begin{document}
\begin{tikzpicture}
\matrix[
mymatrix,
column sep=3em
](mymatr){
&\text{Goal}\\
C_1 & C_2& C_3\\
A_1 & A_2\\
};
\foreach \ind in {1,2,3} {
\draw (mymatr-1-2) -- (mymatr-2-\ind);
\draw (mymatr-3-1) -- (mymatr-2-\ind);
\draw (mymatr-3-2) -- (mymatr-2-\ind);
}
\end{tikzpicture}
\begin{tikzpicture}
\matrix[
mymatrix,
column sep=1.5em
](mymatr){
&&\text{Goal}\\
C_1 && C_2&& C_3\\
&A_1 && A_2\\
};
\foreach \ind in {1,3,5} {
\draw (mymatr-1-2) -- (mymatr-2-\ind);
\draw (mymatr-3-2) -- (mymatr-2-\ind);
\draw (mymatr-3-4) -- (mymatr-2-\ind);
}
\end{tikzpicture}
\end{document}