评论

评论

我尝试使用 Tikz 绘制具有特定拓扑的大型图形,但遇到了一些问题。由于并非所有节点都可以明确表示,因此我不得不使用省略号。我尝试将此省略号定义为节点,但这些点水平显示,而不是如图所示,也就是说,如果省略号是其他节点所在的圆周上的三个相邻点,那就太好了。

即使我有一个完整的图表,也会出现同样的问题。有人能帮我解决这个问题吗?谢谢!

星星 完全的

目前代码:

\begin{tikzpicture}[->,>=stealth', shorten>=1pt, auto, node distance=2.8cm, semithick]
 \tikzstyle{peer}=[draw,circle,violet,bottom color=\lav, top color= white, text=violet, minimum width=8pt]
 \tikzstyle{superpeer}=[draw, circle, burntorange, left color=\oran, text=violet, minimum width=25pt]
  \node[superpeer] (A) {$0$};
  \node[peer]         (B)  at ($ (A) + (20:4) $) {$1$};
  \node[peer]         (C)  at ($ (A) + (-52:4) $) {$2$};
  \node[peer]         (D)   at ($ (A) + (-124:4) $){$3$};
  \node[draw=none] (F)  at ($ (A) + (-176:4) $){$\cdots$};  
  \node[peer] (E) at ($ (A) + (92:4) $) {$N$};

  \path (A) edge [color=blue, sloped] node[]{$\lambda_{01}, \mu_{01}$} (B);
  \path (A) edge [color=blue, sloped] node[] {$\lambda_{02}, \mu_{02}$} (C);
  \path (A) edge [color=blue, sloped] node[] {$\lambda_{03}, \mu_{03}$}(D);
  \path (A) edge [color=blue, sloped, below] node[] {$\lambda_{0N}, \mu_{0N}$} (E);
  \path (B) edge [color=blue, sloped] node[] {$\lambda_{10}, \mu_{10}$}(A);
  \path (C) edge [color=blue, sloped] node[] {$\lambda_{20}, \mu_{20}$}(A);
  \path (D) edge [color=blue, sloped] node[] {$\lambda_{30}, \mu_{30}$}(A);
  \path (E) edge [color=blue, sloped, above] node[] {$\lambda_{N0}, \mu_{N0}$}(A);
\end{tikzpicture}

答案1

这是另一种可能的解决方案。由于没有\lav颜色定义,因此red使用。解决方案使用(A.<angle>)在节点之间绘制的两条线。这些线-20 <center angle> +20相距度。p1, p1 and p2可以调整以显示它们之间的接近度

在此处输入图片描述

代码

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,arrows,shadows,calc,positioning,automata}
\usepackage{xcolor}
\usetikzlibrary{shapes}
\begin{document}

\tikzset{%
peer/.style={draw,circle,violet,bottom color=red, top color= white, text=violet, minimum width=25pt},
superpeer/.style={draw, circle,  left color=orange, text=violet, minimum width=25pt},
point/.style = {fill=black,inner sep=2pt, ellipse, minimum width=10pt,align=right,rotate=60},
forward edge/.style={->, >=stealth, shorten >=0pt, thick, color=blue},
}
\begin{tikzpicture}[auto, node distance=2.8cm]

  \node[superpeer] (A) {$0$};
  \node[peer]  (B)   at ($ (A) + (18:4) $){$1$};  % 72 degree apart
  \node[peer]  (C)   at ($ (A) + (306:4)$){$2$};
  \node[peer]  (D)   at ($ (A) + (234:4)$){$3$};
  \node[point] (p1)  at ($ (A) + (172:4) $){};  
  \node[point] (p2)  at ($ (A) + (162:4) $){};            % center angle  
  \node[point] (p3)  at ($ (A) + (152:4) $){};  
  \node[peer] (E) at ($ (A) + (90:4) $) {$N$};

\path [forward edge] (A.38) edge [sloped,above=1cm] node[label=above:{$\lambda_{01}$}]{}(B.178);
\path [forward edge,] (B.218) edge [sloped,below=1cm] node[label=below:{$\mu_{01}$}]{} (A.-2);

 \path [forward edge] (A.326) edge [sloped] node[] {$\lambda_{02}$} (C.106);
 \path [forward edge] (C.146) edge [sloped] node[] {$\mu_{02}$} (A.286);

  \path [forward edge] (A.214) edge [sloped] node[label={[shift={(0ex,-1ex)}]above:{$\lambda_{03}$}}] {}(D.74);
  \path [forward edge] (D.34) edge [sloped] node[label={[shift={(0ex,2ex)}]below:{$\mu_{03}$}}] {}(A.254);

 \path [forward edge] 
(A.70) edge [sloped] node[label={[shift={(-3ex,-1ex)}]left:{$\lambda_{0N}$}}] {} (E.290) 
(E.250) edge [sloped] node[label={[shift={(-3ex,-1ex)}]right:{$\mu_{0N}$}}] {} (A.110);
\end{tikzpicture}



\end{document}

答案2

评论

我猜你的问题是,如何旋转这些点,使它们与你发布的示例图片相匹配。我们知道,因此它需要与从原点指向那里的路径正交。通过一些简单的数学运算,我们发现

-176 + 90 = -86

因此节点需要旋转-86°。

\node[rotate=-86] (F) at ($(A) + (-176:4)$) {\mydots};

为了获得缩放点,我引入了一个宏\mydots。如果你想在 OT1 编码中使用默认的 Computer Modern 字体,你可能需要声明

\newcommand*\mydots{{\Huge$\cdots$}}

如果你加载了可缩放字体,比如 Latin Modern,则可以指定任意大的点

\usepackage{lmodern}
\newcommand*\mydots{{\fontsize{60}{80}\selectfont$\cdots$}}

(如果您想在其他情况下使用它并且不希望周围环境也缩放,我添加了额外的分组级别)

完整示例

\PassOptionsToPackage{dvipsnames}{xcolor}
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,calc}
\newcommand*\lav{Lavender}
\newcommand*\oran{Orange}
% We need a scalable font for this
\usepackage{lmodern}
\newcommand*\mydots{{\fontsize{60}{80}\selectfont$\cdots$}}
%\newcommand*\mydots{{\Huge$\cdots$}}% <- Without scalable font
\tikzset{
    peer/.style={
        draw,
        circle,
        violet,
        bottom color=\lav,
        top color= white,
        text=violet,
        minimum width=8pt
    },
    superpeer/.style={
        draw,
        circle,
        BurntOrange,
        left color=\oran,
        text=violet,
        minimum width=25pt
    }
}
\begin{document}
\begin{tikzpicture}[
        ->,
        >=stealth',
        shorten >=1pt,
        auto,
        node distance=2.8cm,
        semithick
    ]
    \node[superpeer]  (A)                       {$0$};
    \node[peer]       (B) at ($(A) + (20:4)$)   {$1$};
    \node[peer]       (C) at ($(A) + (-52:4)$)  {$2$};
    \node[peer]       (D) at ($(A) + (-124:4)$) {$3$};
    \node[rotate=-86] (F) at ($(A) + (-176:4)$) {\mydots};  
    \node[peer]       (E) at ($(A) + (92:4)$)   {$N$};

    \path (A) edge[color=blue,sloped]       node {$\lambda_{01}, \mu_{01}$} (B);
    \path (A) edge[color=blue,sloped]       node {$\lambda_{02}, \mu_{02}$} (C);
    \path (A) edge[color=blue,sloped]       node {$\lambda_{03}, \mu_{03}$} (D);
    \path (A) edge[color=blue,sloped,below] node {$\lambda_{0N}, \mu_{0N}$} (E);
    \path (B) edge[color=blue,sloped]       node {$\lambda_{10}, \mu_{10}$} (A);
    \path (C) edge[color=blue,sloped]       node {$\lambda_{20}, \mu_{20}$} (A);
    \path (D) edge[color=blue,sloped]       node {$\lambda_{30}, \mu_{30}$} (A);
    \path (E) edge[color=blue,sloped,above] node {$\lambda_{N0}, \mu_{N0}$} (A);
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容