如何使用 tikz-network 包实现两个顶点之间的双向边?

如何使用 tikz-network 包实现两个顶点之间的双向边?

我正在尝试使用 tikz-network 包绘制网络图。网络需要在两个顶点之间有一条双向边。下面的代码创建了一个方向的边。我读了文档,它似乎没有提供任何选项来实现双向边。有没有专家能指点一下如何实现双向边?

\documentclass[]{standalone}
\usepackage{tikz-network}

\makeatletter
\tikzset{network x offset/.initial=1ex,network y offset/.initial=1ex,
adjust size/.style={minimum width=width("\vertex@Label")+2*\pgfkeysvalueof{/tikz/network x offset},
minimum height=height("\vertex@Label")+2*\pgfkeysvalueof{/tikz/network y offset}}}
\makeatother

\begin{document}

\begin{tikzpicture}

% Parnters
    \Vertex[color=cyan, x=0, y=0, label=A, shape=rectangle, style={adjust size}]{PG}
    \Vertex[color=cyan, x=0, y=-4, label=B, shape=rectangle, style={adjust size}]{PHP}
    \Vertex[color=cyan, x=0, y=-6, label=C, shape=rectangle, style={adjust size}]{PSM}
%Product
    \Vertex[color=orange, x=8, y=-2, label=D, shape=rectangle, style={adjust size}]{PRD}
%Customers
    \Vertex[color=yellow, x=16, y=0, label=A, shape=rectangle, style={adjust size}]{CSTG}
    \Vertex[color=yellow, x=16, y=-4, label=E, shape=rectangle, style={adjust size}]{CSTE} 
    \Vertex[color=yellow, x=16, y=-7, label=A, shape=rectangle, style={adjust size}]{CSTA} 
%Competetors
    \Vertex[color=white, x=24, y=0, label=C, shape=rectangle, style={adjust size}]{CC}    
    \Vertex[color=white, x=24, y=-4, label=S, shape=rectangle, style={adjust size}]{CSPKT}  

% Relationships from Product to Partners
    \Edge[lw=1, Direct, label=D](PRD)(PG)
    \Edge[lw=1, Direct, label=S](PRD)(PHP)
    \Edge[lw=1, Direct, label=U](PRD)(PSM)   

% Relationships from Product to Customers
    \Edge[lw=1, Direct, label=H](PRD)(CSTG)
    \Edge[lw=1, Direct, label=C](PRD)(CSTE)
    \Edge[lw=1, Direct, label=C](PRD)(CSTA)    
    
% Relationships from Competitors to Customers
    \Edge[lw=1, Direct, label=C](CSTE)(CC)
    \Edge[lw=1, Direct, label=C](CSTE)(CSPKT)
\end{tikzpicture}

\end{document}

答案1

例如你可以使用

\Edge[lw=1, style={latex-latex}, label=D](PRD)(PG)

latex是有向边默认使用的箭头尖类型。

相关内容