这是我一直在使用的工作示例:
\documentclass{standalone}
%======================================
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usegdlibrary{force, layered, trees}
%======================================
\begin{document}
\tikz [spring layout, node distance=25mm]
{
\node (a) {a};
\node (b) {b};
\node (c) {c};
\draw
(a) edge[->] (b)
(b) edge[->] (c)
(c) edge[->] (b.north);
}
\end{document}
我希望边从c
到 到 之间的边的中间,a
但是b
,我当前尝试使用b.north
,却没有任何效果——它甚至没有c
在其他地方绘制一条边。有没有办法可以引用边的“边节点”,以便绘制一条到它的边?
答案1
你在寻找类似的东西吗
\documentclass[tikz,margin=5pt]{standalone}
\usetikzlibrary{graphs,graphdrawing,arrows}
\usegdlibrary{force}
\begin{document}
\tikz[spring layout, node distance=25mm,>=latex']{
\node (a) {a};
\node[cut policy=none] (x) {};
\node (b) {b};
\node (c) {c};
\draw
(a) edge (x)
(x) edge[->] (b)
(b) edge[->] (c)
(c) edge[->] (x);
}
\end{document}
或更短
\documentclass[tikz,margin=5pt]{standalone}
\usetikzlibrary{graphs,graphdrawing,arrows}
\usegdlibrary{force}
\begin{document}
\tikz[spring layout, node distance=25mm,>=latex']
\graph{a--x[as=, cut policy=none]->b->c, c->x};
\end{document}