用边缘绘制

用边缘绘制

我正在画这个图;在此处输入图片描述

我被困在这一点上: 在此处输入图片描述

我需要三件事的帮助:

  1. 我如何从 NFVI 绘制到 OSS。我试过了,但我觉得我遗漏了一些东西
  2. 我如何更改绘制的起点和终点?我知道如何绘制箭头[...,->]。我试过了但不起作用
  3. 最后,我如何添加垂直绘图(如图例所示)

我的代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                backgrounds, bending,
                calc,
                decorations.pathmorphing,
                fit,
                petri,
                positioning}

\usepackage[margin=2.5cm]{geometry}
\usetikzlibrary{arrows.meta}
\definecolor{darkblue}{RGB}{31,22,70}
\definecolor{darkblue2}{RGB}{21,126,251}
\begin{document}
   \begin{tikzpicture}[
            transform shape,
            %show background rectangle,
            background rectangle/.style={fill=gray!20},
            box/.style={draw, font=\itshape}
            ]
            \coordinate (b) at (current page.center);
            \node[rounded corners=3mm, label=center:{OSS/BSS}, fill=darkblue2!20] (OSS)at (b) [draw,minimum width=1.5cm,minimum height=2.4cm] {};

            \node[below=5 cm of OSS,rounded corners=3mm, label=center:{EMS}, fill=darkblue2!20] (ems) [draw,minimum width=2.5cm,minimum height=1.4cm] {};
            \node[below=of ems,rounded corners=3mm, label=center:{VNF}, fill=darkblue2!20] (VNF) [draw,minimum width=2.5cm,minimum height=2.4cm] {};
            \node[below = of VNF,rounded corners=3mm, label=center:{NFVI}, fill=darkblue2!20] (NFVI) [draw,minimum width=3.5cm,minimum height=2.4cm] {};
            \node[below = of VNF,rounded corners=3mm, label=center:{NFVI}, fill=darkblue2!20] (NFVI) [draw,minimum width=3.5cm,minimum height=2.4cm] {};
            \node[right= 2cm of OSS,rounded corners=3mm, label=center:{NFV Orchestrator}, fill=darkblue!20] (NFVO) [draw,minimum width=12cm,minimum height=2.4cm] {};
            \node[below left = 0.5cm and -2cm of NFVO,rounded corners=3mm, label=center:{NS Catalog}, fill=darkblue!20] (NSC) [draw,minimum width=2cm,minimum height=2.4cm] {};
            \node[right= 0.5 cm of NSC,rounded corners=3mm, label=center:{VNF Catalog}, fill=darkblue!20] (VNFC) [draw,minimum width=2cm,minimum height=2.4cm] {};

            \node[below right = 0.5cm and -3cm of NFVO,rounded corners=3mm, label=center:{NFVI ressources}, fill=darkblue!20] (NFVIR) [draw,minimum width=3cm,minimum height=2.4cm] {};
            \node[left= 0.5 cm of NFVIR,rounded corners=3mm, label=center:{NFV Instances}, fill=darkblue!20] (NFVI1) [draw,minimum width=2.5cm,minimum height=2.4cm] {};
            \node[right= 2.5 cm of ems,rounded corners=3mm, label=center:{VNF Manager (VNFM)}, fill=darkblue!20] (VNFM) [draw,minimum width=9cm,minimum height=2.4cm] {};
            \node[right=  2cmof NFVI,rounded corners=3mm, label=center:{Virtualised infrastructure manager (VIM)}, fill=darkblue!20] (VIM) [draw,minimum width=8cm,minimum height=2.4cm] {};
            %Draw form OSS
            \draw[thick,darkblue, dashed](OSS)--(ems);
            \draw[thick,darkblue, dashed](OSS) 
                %to  [out=180](8,0)
                %to [in=180](NFVI) ;
                --(NFVI);
            \draw[thick,darkblue, dashed](OSS)--(NFVO)node [midway, above]{Os-Ma-nfvo};
            %Draw form ems
            \draw[thick,darkblue, dashed](ems)--(VNF);
            \draw[thick,darkblue, dashed](ems)--(VNFM)node [midway, above]{Ve-En-Vnfm};
            %Draw from VNF
            \draw[thick,darkblue, dashed, circle](VNF)--(NFVI)node [midway, right]{Vn-Nf};
            %Draw from VNFC
            \draw[thick,darkblue, dashed](VNFC)--(NFVO);
            %Draw from VNFM           
            \draw[thick,darkblue, dashed](VNFM)--(VNF)node [midway, below]{VeNf-Vnfm};
           %     to [out=270](NFVI)node [midway, right]{Vn-Nf};
           \draw[thick,darkblue, dashed](VNFM)--(NFVO)node [midway, right]{Or-Vnfm};
           \draw[thick,darkblue, dashed](VNFM)--(VIM)node [midway, right]{Vnfm-VI};
           %Draw from NFVI
           \draw[thick,darkblue, dashed](NFVI)--(VIM)node [midway, above]{Nf-VI};
           %draw from vim
           \draw[thick,darkblue, dashed](VIM)--(NFVO)node [midway, right]{Or-Vnfm};

           %draw form nfvo
           \draw[thick,darkblue, dashed](NFVO)--(NSC);
           \draw[thick,darkblue, dashed](NFVO)--(NFVI1);
           \draw[thick,darkblue, dashed](NFVO)--(NFVIR);

           \node[fit=(NFVO)(VIM), draw, dashed] {};  
   \end{tikzpicture}
\end{document}

答案1

嗎,像这样?

在此处输入图片描述

几乎从零开始......

\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                backgrounds, bending,
                calc, chains,
                %decorations.pathmorphing,
                fit,
                %petri,
                positioning,
                quotes,
                shapes.misc}

\definecolor{darkblue}{RGB}{31,22,70}
\definecolor{darkblue2}{RGB}{21,126,251}
\begin{document}
    \begin{tikzpicture}[
node distance = 12mm and 2mm,
  start chain = A going right,
   box/.style = {% blue box
        draw,  
        text width=#1, minimum height=12mm, align=center},
 box/.default = 16 mm,
  bbox/.style = {% blue box
        draw, rounded corners=3mm, fill=darkblue2!20,
        text width=17mm, minimum height=12mm, align=center},
  cbox/.style = {% chamfered (rectangle) box
        chamfered rectangle, chamfered rectangle corners=north west, draw, 
        minimum width=18mm, minimum height=8mm, align=flush center,
        text width=\pgfkeysvalueof{/pgf/minimum width} - 2*\pgfkeysvalueof{/pgf/inner xsep},
        on chain= A},
every edge quotes/.append style = {fill=white, font=\footnotesize, inner sep=2pt}
            ]
% second level
\node   [cbox]  {NS Catalog};
\node   [cbox]  {VNF Catalog};
\node   [cbox,draw=none]    {};  % for empty space in chain
\node   [cbox]  {NFV Instances};
\node   [cbox]  {NFVI ressources};
% top level
\path   let \p1 = ($(A-1.west)-(A-5.east)$),
            \n1 = {veclen(\x1,\y1)} in
        node (NFVO) [box=\n1-2*\pgfkeysvalueof{/pgf/inner xsep}, 
                     above=of A-3]              {NFV Orchestrator};
% third level
\path   let \p1 = ($(A-2.west)-(A-4.east)$),
            \n1 = {veclen(\x1,\y1)} in
        node (VNFM)  [box=\n1, below=of A-3]   {VNF Manager (VNFM)} 
% fourth level
        coordinate[below=of VNFM] (aux1)
% fifth level
        node (VIM)  [box=\n1, below=of aux1]   {Virtualised infrastructure manager};
% left column
    \begin{scope}[node distance=18mm]
\node (OSS) [bbox, left=of NFVO]    {OSS/BSS};
\node (EMS) [bbox, left=of A-1]     {EMS};
\node (EM)  [bbox, left=of NFVO.west |- VNFM] {EM};
\node (VNF) [bbox, left=of NFVO.west |- aux1] {VNF};
\node (NFVI) [bbox,left=of NFVO.west |- VIM]  {NFVI};
    \end{scope}
% dashed frame
\node[draw, ultra thick, dashed, inner sep=9mm, xshift=-2mm,
      fit= (NFVO) (VIM),
      label={[anchor=south east, font=\large\bfseries]below right:NFV-MANO}] {};
% first column
\draw[thick,darkblue, dashed]
    (OSS) -- (EMS)  (EMS) -- (EM)   (EM) -- (VNF)   
    (NFVI.west) -- ++ (-.5,0) |- (OSS)
% top level - second level
    (NFVO.south -| A-1) -- (A-1)
    (NFVO.south -| A-2) -- (A-2)
    (NFVO.south -| A-4) -- (A-4)
    (NFVO.south -| A-5) -- (A-5);
\path[thick,draw=darkblue,fill=darkblue]
    (VNF.south) circle (1mm) -- (NFVI.north)  circle (1mm);
% first column to second column
\draw[ultra thick,darkblue]
    (OSS)   to ["Os-Ma-nfvo"] (NFVO)
    (EM)    to [pos=0.7,"Ve-Vnfm-rm"] (VNFM)
    (NFVI)  to ["Vn-Nf"]      (VIM)
    ([yshift=-2mm] VNFM.west) to ["Ve-Vnfm-wmf"] ++ (-3,0) |- (VNF)
% from top to fourth level
    (NFVO) to [pos=0.25,"Or-Vnfm"] (VNFM)
    (VNFM) to ["Vi-Vnfm"] (VIM)
    (NFVO.east) -| ([xshift=4mm] NFVO.east |- VIM) 
                to ["Or-VI"] (VIM);
   \end{tikzpicture}
\end{document}
  • 我不知道正交线相对于连接线有多重要。我猜它们应该指定总线/数据字的宽度。但是,这些数据被遗漏了,所以我省略了它们。
  • 在绘制这种相对复杂的图表时,首先定义图像中使用的样式是一种很好的做法。我定义了三种:(box用于简单矩形)、bbox(带圆角的蓝色框)用于左列中的节点,以及cbox(用于右列中的地图)用于倒角矩形。有了这个,主代码(图像主体)会变得更短更清晰。
  • 对于边缘标签,我使用quotes库。
  • 图像我从右列节点的第二级开始绘制。cbox所有其他节点都相对于该节点定位。
  • 我希望代码中的注释有助于理解代码的某些部分“在做什么”

如果您对代码有疑问,请随时询问。

相关内容