这里我画了一个 DAG。如果可能的话,我想用曲线把它剪下来。
我的代码:
\documentclass[journal,onecolumn]{IEEEtran}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,positioning, arrows.meta}
\usetikzlibrary{shapes.geometric, arrows, shadows, decorations.text}
\begin{document}
\begin{figure}[!htp]
\centering
\begin{tikzpicture}
[vertex/.style={circle,draw=black,fill=white},
node distance=2cm,
on grid,
>=latex
]
% \draw[gray!50] (-1,-2) grid (5,2);
\node[vertex] (A) {$J5$};
\node[vertex,above left=1cm and 1cm of A] (B) {$J4$};
\node[vertex,below=of B] (C) {$J3$};
\node[vertex,left=of A] (D) {$J2$};
\node[vertex,left=of D] (F) {$J1$};
\draw[->]
(C) edge (A)
(B) edge (A)
(D) edge (C)
(D) edge (B)
(F) edge (D);
\end{tikzpicture}
\end{figure}
\end{document}
输出:
想要的输出:
答案1
嗯,你需要以某种方式找到剪辑的起点和终点。在这里,我只是使用垂直线的交点通过你的节点。
一个切口是直线,另一个切口是绕 J2 的曲线,通过以下方式完成bend left
和一个min distance
。
我将提供两种cut line
样式:一种使用random steps
装饰,一种只是虚线。
代码
\documentclass[tikz]{standalone}
%\documentclass[journal,onecolumn]{IEEEtran}
%\usepackage{hyperref}
%\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, positioning, arrows.meta, angles}
\tikzset{
cut line/.style={
rounded corners=\pgfdecorationsegmentamplitude,
decoration={name=random steps}, decorate},
% cut line/.style=dashed,
}
\pgfmathsetseed{693069} % reproducable output
\begin{document}
%\begin{figure}[!htp]
% \centering
\begin{tikzpicture}[
vertex/.style={circle, draw=black}, node distance=2cm, on grid, >=Latex]
\node[vertex] (J5) {$J5$};
\node[vertex, above left=1cm and 1cm of J5] (J4) {$J4$};
\node[vertex, below=of J4] (J3) {$J3$};
\node[vertex, left=of J5] (J2) {$J2$};
\node[vertex, left=of J2] (J1) {$J1$};
\path[->] (J1) edge (J2) (J2) edge (J4) edge (J3) (J4) edge (J5) (J3) edge (J5);
\draw[red, cut line] (J2|-J4) -- (J5|-J3);
\end{tikzpicture}
\begin{tikzpicture}[
vertex/.style={circle, draw=black}, node distance=2cm, on grid, >=Latex]
\node[vertex] (J5) {$J5$};
\node[vertex, above left=1cm and 1cm of J5] (J4) {$J4$};
\node[vertex, below=of J4] (J3) {$J3$};
\node[vertex, left=of J5] (J2) {$J2$};
\node[vertex, left=of J2] (J1) {$J1$};
\path[->] (J1) edge (J2) (J2) edge (J4) edge (J3) (J4) edge (J5) (J3) edge (J5);
\draw[red, cut line] (J2|-J4) to[bend left=45, min distance=1.2cm] (J2|-J3);
\end{tikzpicture}
%\end{figure}
\end{document}