如何在 Tikz 中创建有向图的凝聚?
目标 1 左边是一个有向图,即有向图,右边是它的浓缩,来源是《Handbook of Graph Theory》第 183 页。希望在聊天。
目标 2与上面相同,但示例更简单。
试验 2
微波辐射计 2
\begin{tikzpicture}[x=2cm, y=2cm]
\tikzstyle{every node}=[draw, circle, fill=white, inner sep=3pt,minimum size=18pt]
%1
\draw (0,0) node(1111){1};
\draw (1,0) node(2222){2};
%2
\draw (3,0) node(1){1};
\draw (4,0) node(111){1};
\draw (5,0) node(2){2};
\draw (6,0) node(222){2};
\draw (7,0) node(3){3};
\draw[->](1)--(111);
\draw[<->](111)--(2);
\draw[->](2)--(222);
\draw[<->](222)--(3);
\node[left] at (0.8,-0.5) {(a)};
\node[left] at (5.2,-0.5) {(b)};
%-----------
%1
\draw (0,-1) node(1111){1};
\draw (1,-1) node(2222){2};
%2
\draw (3,-1) node(1){1};
\draw (4,-1) node(111){1};
\draw (5,-1) node(2){2};
\draw (6,-1) node(222){2};
\draw (7,-1) node(3){3};
\draw[->](1)--(111);
\draw[<->](111)--(2);
\draw[->](2)--(222);
\draw[<->](222)--(3);
\node[left] at (0.8,-1.5) {(a)$^*$};
\node[left] at (5.2,-1.5) {(b)$^*$};
\end{tikzpicture}
也许相关线索
答案1
我不知道你为什么拒绝发布可编译代码,但无论如何。
无论如何,对于类似的东西,我会用它fit
来绘制 2 个以上节点的边界。我会使用链或 TikZ 图形来绘制图形本身。
例如,使用一个简单的链(这里不需要图表):
\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{chains, fit}
\begin{document}
\begin{tikzpicture}[start chain=main going right, every on chain/.append style={circle, draw}]
\node [on chain] {1};
\node [on chain, join={by ->}] {1};
\node [on chain, join={by <->}] {2};
\node [on chain, join={by ->}] {2};
\node [on chain, join={by <->}] {3};
\foreach \i/\j in {2/3,4/5}
\node [fit=(main-\i) (main-\j), draw, rounded corners] {};
\end{tikzpicture}
\end{document}
或者以图表形式呈现:
\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{fit, graphs}
\begin{document}
\begin{tikzpicture}
\graph [grow right, nodes={draw, circle}, /tikz/every label/.append style={label distance=10pt}] {
a/"1" -> 1 <-> 2[label=below:(b)*] -> b/"2" <-> 3
};
\foreach \i/\j in {1/2,b/3}
\node [fit=(\i) (\j), draw, rounded corners] {};
\end{tikzpicture}
\end{document}
答案2
对 cfr 图表解决方案进行了重新设计,将两个图表并排放置,这源于我们与艾伦。
\begin{tikzpicture}
\graph [grow right, nodes={draw, circle}, /tikz/every label/.append style={label distance=5pt}] {
a/"1" -> 1[label=above:$S_1$] <-> 2[label=below:(b) $x_1+x_1x_2+x_2x_3$] -> b/"2"[label=above:$S_2$] <-> 3
};
\foreach \i/\j in {1/2,b/3}
\node [fit=(\i) (\j), draw, rounded corners] {};
\begin{scope}[xshift=.5\linewidth]
\graph [grow right, nodes={draw, circle}, /tikz/every label/.append style={label distance=5pt}] {
1 -> b/$S_1$[label=below:(b)* ] -> c/$S_2$
};
\end{scope}
\end{tikzpicture}
Ps\usetikzlibrary{fit, graphs}
需要放在你的序言中,请参阅 cfr 的解决方案。