我想用 Ti 绘制超图钾Z 看起来像这样
我目前拥有的:
\usepackage{tikz}
\usetikzlibrary{calc, positioning, fit, shapes.misc}
\begin{document}
\begin{tikzpicture}
[
he/.style={draw, rounded corners}, % he = hyper edge
ce/.style={draw, dashed, rounded corners} % ce = condition edge
]
\node (f) at (0,0) {$F$};
\node (g) at (1,0) {$G$};
\node (e) at (2,0) {$E$};
\node (d) at (2,1) {$D$};
\node (a) at (2,2) {$A$};
\node (b) at (3,2) {$B$};
\node [he, fit=(f) (g)] {};
\node [ce, fit=(g) (e)] {};
\node [he, fit=(a) (d) (e)] {};
\node [ce, fit=(a) (b) (d)] {};
\end{tikzpicture}
\end{document}
我没能做到..
- 使超边稍微小一点,就像原图一样,这样你就可以区分超边和条件边
- 将 ABD 条件边设为圆角三角形
您知道如何做吗?此外,这是我第一次与 Ti 合作钾Z,所以如果您对如何改进创建此图表的方式以及如何定义样式有任何其他建议,我会很乐意了解更多。
答案1
您可以更改inner sep
超边或条件边,以便它们都具有不同的大小。
对于第二部分,我没有使用fit
库的好解决方案。我只是画出了那个条件边。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, positioning, fit, shapes.misc}
\begin{document}
\begin{tikzpicture}
[
he/.style={draw, rounded corners,inner sep=0pt}, % he = hyper edge
ce/.style={draw,dashed, rounded corners=10pt}, % ce = condition edge
]
\node (f) at (0,0) {$F$};
\node (g) at (1,0) {$G$};
\node (e) at (2,0) {$E$};
\node (d) at (2,1) {$D$};
\node (a) at (2,2) {$A$};
\node (b) at (3,2) {$B$};
\node [he, fit=(f) (g)] {};
\node [ce, fit=(g) (e)] {};
\node [he, fit=(a) (d) (e)] {};
\node [fit=(a) (b) (d)] (fd){};
\draw [dashed,rounded corners=10pt] ($(fd.south west)+(0,-0.5)$) -- (fd.north west) -- ($(fd.north east)+(0.5,0)$)--cycle;
\end{tikzpicture}
\end{document}
答案2
您可以使用我的(半)图书馆(https://gitlab.com/gruenwald/tikz-hypergraphs) 我就是为此目的而做的:
\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen} % For tikz-hypergraph
\usetikzlibrary{calc} % For tikz-hypergraph
\input{tikz-hypergraph}
\begin{document}
\begin{tikzpicture}
[
he/.style={draw, semithick}, % he = hyper edge
ce/.style={draw, dashed, semithick}, % ce = condition edge
]
\node (f) at (0,0) {$F$};
\node (g) at (1,0) {$G$};
\node (e) at (2,0) {$E$};
\node (d) at (2,1) {$D$};
\node (a) at (2,2) {$A$};
\node (b) at (3,2) {$B$};
\draw[he] \hedgeii{a}{b}{3mm};
\draw[he] \hedgeii{a}{e}{3mm};
\draw[ce] \hedgeiii{a}{b}{d}{4mm};
\draw[ce] \hedgeii{g}{e}{4mm};
\draw[he] \hedgeii{f}{g}{3mm};
\end{tikzpicture}
\end{document}