重现带标记边的有向图

重现带标记边的有向图

我正在尝试实现以下图表:

这里

我想到了一个 MWE,但无法绘制弯曲的边缘。代码如下所示:

        \documentclass[11pt]{scrartcl} 
        \PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor}  
        \usepackage{tikz}
        \usetikzlibrary{arrows,positioning,automata}

        \begin{document}
        \begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=3cm,on grid,initial/.style    ={}]
          \node[state]          (A)                        {$Author$};
          \node[state]          (P) [above right =of A]    {$Paper$};
          \node[state]          (T) [below right =of A]    {$Topic$};
          \node[state]          (V) [below right =of P]    {$Venue$};
        \tikzset{mystyle/.style={->,double=orange}} 
        \tikzset{every node/.style={fill=white}} 
        \path (V)     edge [mystyle]    node   {$publish$} (P)
              (P)     edge [mystyle]    node   {$mention$} (T)
              (T)     edge [mystyle]    node   {$mention-1$} (P)
              (P)     edge [mystyle]    node   {$write-1$} (A)
              (T)     edge [mystyle]    node   {$contain$} (T);
        \tikzset{mystyle/.style={double=orange}}   
        \tikzset{mystyle/.style={<->,relative=false,in=0,out=60,double=orange}}
        \end{tikzpicture}
        \end{document}

答案1

一种方法是使用以下to[ <options> ]语法:

\draw [red, ultra thick, ->] (A.north west) to[out=190, in=170, distance=1.5cm] (A.south west);
\draw [red, ultra thick, ->] (T.-150) to[out=-80, in=-100, distance=1.5cm] (T.-30);

您可以通过罗盘方向或使用角度指定曲线的终点,(A.north west)(T.-150),并控制in=角度out=以及distance=

在此处输入图片描述

笔记:

  • 不确定你为什么要这样做\tikzset\end{tikzpicture}我删除了该部分代码,因为它在这里不起作用。

代码:

\documentclass[11pt]{scrartcl} 
\PassOptionsToPackage{usenames,dvipsnames,svgnames}{xcolor}  
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata}

\begin{document}
\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=3cm,on grid,initial/.style    ={}]
  \node[state]          (A)                        {$Author$};
  \node[state]          (P) [above right =of A]    {$Paper$};
  \node[state]          (T) [below right =of A]    {$Topic$};
  \node[state]          (V) [below right =of P]    {$Venue$};
\tikzset{mystyle/.style={->,double=orange}} 
\tikzset{every node/.style={fill=white}} 
\path (V)     edge [mystyle]    node   {$publish$} (P)
      (P)     edge [mystyle]    node   {$mention$} (T)
      (T)     edge [mystyle]    node   {$mention-1$} (P)
      (P)     edge [mystyle]    node   {$write-1$} (A)
      (T)     edge [mystyle]    node   {$contain$} (T);
      
\draw [red, ultra thick, ->] (A.north west) to[out=190, in=170, distance=1.5cm] (A.south west);
\draw [red, ultra thick, ->] (T.-150) to[out=-80, in=-100, distance=1.5cm] (T.-30);

\end{tikzpicture}
\end{document}

相关内容