2020-04-25 14:19发布
[图] 这两张图有什么简便的画法吗,不要求细节完全一样,能体现出这种思想即可
这两张图有什么简便的画法吗,不要求细节完全一样,能体现出这种思想即可
闲来无事,模仿你的图。
\documentclass[tikz]{standalone}\usepackage{tikz}\usetikzlibrary[ arrows.meta, bending, backgrounds, graphs, graphs.standard, ]\begin{document}\begin{tikzpicture}[>=Latex] \graph [ color class=c-0, color class=c-1,color class=c-2,color class=c-3, nodes={draw, circle},empty nodes, branch right, grow down]{ [complete bipartite={c-0}{c-1},complete bipartite={c-1}{c-2},complete bipartite={c-2}{c-3},<-] x[c-0,], {[placement/width=1,placement/depth=-2] subgraph I_n [name=lA,c-1,V={1,...,5}] }, {[placement/width=2,placement/depth=-2] subgraph I_n [name=lB,c-2,V={1,...,5},], }, {[placement/width=3,placement/depth=-2] subgraph I_n [name=lC,c-3,V={1,...,5},], },};\end{tikzpicture}\begin{tikzpicture}[>=Latex]\def\mycircleradius{2mm}\graph [ color class=c-0, color class=c-1,color class=c-2,color class=c-3, nodes={circle,minimum width=2*\mycircleradius},empty nodes,branch right, grow down]{[complete bipartite={c-0}{c-1},complete bipartite={c-1}{c-2},complete bipartite={c-2}{c-3},<-] {[placement/width=0,placement/depth=3]0[c-0]}, {[placement/width=1] \foreach \i in {1,3,5} { {[placement/depth=\i]\i[c-1]}, }, \foreach \i in {2,4} { {[placement/depth=\i]\i[!c-1]}, } }, {[placement/width=2] \foreach \i[evaluate={ \mmm = \i-5;}] in {7,10} { {[placement/depth=\mmm]\i[c-2]}, }, \foreach \i[evaluate={ \mmm = \i-5;}] in {6,8,9} { {[placement/depth=\mmm]\i[!c-2]}, } }, {[placement/width=3] \foreach \i[evaluate={ \mmm = \i-10;}] in {11,14,15} { {[placement/depth=\mmm]\i[c-3]}, }, \foreach \i[evaluate={ \mmm = \i-10;}] in {12,13} { {[placement/depth=\mmm]\i[!c-3]}, } },};\begin{scope}[on background layer] \foreach \i in {2,4,6,8,9,12,13} { \draw [densely dotted](\i) circle [radius=\mycircleradius]; \draw (\i.135)--(\i.-45); \draw (\i.45)--(\i.225); } \foreach \i in {0,1,...,15} { \global\def\donotdraw{0} \foreach \j in {2,4,6,8,9,12,13} { \ifnum\i=\j\relax \global\def\donotdraw{1} \fi } \ifnum\donotdraw=1\relax \else \draw (\i) circle [radius=\mycircleradius]; \fi }\end{scope}\end{tikzpicture}\end{document}
主要用了 TikZ 的 graphs, graphs.standard 这两个库。
另外也有 graphdrawing 库可用。
也有 tkz-graph 宏包,这个包的作者 也是 tkz-euclide 包的作者,手册好像是法文的。
最多设置5个标签!
闲来无事,模仿你的图。
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary[
arrows.meta,
bending,
backgrounds,
graphs,
graphs.standard,
]
\begin{document}
\begin{tikzpicture}[>=Latex]
\graph [
color class=c-0, color class=c-1,color class=c-2,color class=c-3,
nodes={draw, circle},empty nodes,
branch right, grow down]
{ [complete bipartite={c-0}{c-1},complete bipartite={c-1}{c-2},complete bipartite={c-2}{c-3},<-]
x[c-0,],
{[placement/width=1,placement/depth=-2]
subgraph I_n [name=lA,c-1,V={1,...,5}]
},
{[placement/width=2,placement/depth=-2]
subgraph I_n [name=lB,c-2,V={1,...,5},],
},
{[placement/width=3,placement/depth=-2]
subgraph I_n [name=lC,c-3,V={1,...,5},],
},
};
\end{tikzpicture}
\begin{tikzpicture}[>=Latex]
\def\mycircleradius{2mm}
\graph [
color class=c-0, color class=c-1,color class=c-2,color class=c-3,
nodes={circle,minimum width=2*\mycircleradius},empty nodes,branch right, grow down]
{[complete bipartite={c-0}{c-1},complete bipartite={c-1}{c-2},complete bipartite={c-2}{c-3},<-]
{[placement/width=0,placement/depth=3]0[c-0]},
{[placement/width=1]
\foreach \i in {1,3,5}
{
{[placement/depth=\i]\i[c-1]},
},
\foreach \i in {2,4}
{
{[placement/depth=\i]\i[!c-1]},
}
},
{[placement/width=2]
\foreach \i[evaluate={ \mmm = \i-5;}] in {7,10}
{
{[placement/depth=\mmm]\i[c-2]},
},
\foreach \i[evaluate={ \mmm = \i-5;}] in {6,8,9}
{
{[placement/depth=\mmm]\i[!c-2]},
}
},
{[placement/width=3]
\foreach \i[evaluate={ \mmm = \i-10;}] in {11,14,15}
{
{[placement/depth=\mmm]\i[c-3]},
},
\foreach \i[evaluate={ \mmm = \i-10;}] in {12,13}
{
{[placement/depth=\mmm]\i[!c-3]},
}
},
};
\begin{scope}[on background layer]
\foreach \i in {2,4,6,8,9,12,13}
{
\draw [densely dotted](\i) circle [radius=\mycircleradius];
\draw (\i.135)--(\i.-45);
\draw (\i.45)--(\i.225);
}
\foreach \i in {0,1,...,15}
{
\global\def\donotdraw{0}
\foreach \j in {2,4,6,8,9,12,13}
{
\ifnum\i=\j\relax
\global\def\donotdraw{1}
\fi
}
\ifnum\donotdraw=1\relax
\else
\draw (\i) circle [radius=\mycircleradius];
\fi
}
\end{scope}
\end{tikzpicture}
\end{document}
主要用了 TikZ 的 graphs, graphs.standard 这两个库。
另外也有 graphdrawing 库可用。
也有 tkz-graph 宏包,这个包的作者 也是 tkz-euclide 包的作者,手册好像是法文的。
一周热门 更多>