如何在 Latex 上制作图形(节点和边)?

Hct*_*sol 0 latex graph-theory graph nodes

我在乳胶中新编码,我想制作高质量的图(节点和边),特别是我需要制作这种图。图形

这甚至可能吗?

Jou*_*leV 5

这不仅是“甚至可能”,而且总是可能的。使用 Ti k Z 和类似的包可以轻松创建这种图表。

如果你已经有了节点的坐标,箭头的方向等等,你可以从这里开始。这不是您的图表,而是一个很好的起点。

\documentclass[tikz,margin=3]{standalone}
\usetikzlibrary{shadows} % Shadows for nodes
\begin{document}
\begin{tikzpicture}
\tikzset{% This is the style settings for nodes
    dep/.style={circle,minimum size=1cm,fill=orange!20,draw=orange,
                general shadow={fill=gray!60,shadow xshift=1pt,shadow yshift=-1pt}},
    cli/.style={circle,minimum size=1cm,fill=white,draw,
                general shadow={fill=gray!60,shadow xshift=1pt,shadow yshift=-1pt}},
    spl/.style={cli,append after command={
                  node[circle,draw,dotted,
                       minimum size=1.5cm] at (\tikzlastnode.center) {}}},
    c1/.style={-stealth,very thick,red!80!black},
    v2/.style={-stealth,very thick,yellow!65!black},
    v4/.style={-stealth,very thick,purple!70!black}}
\node[dep] (0) at (0,0) {0};
\node[cli] (7) at (-1,-2) {7};
\node[spl] (8) at (2,-2) {8};
\draw[c1] (0) to[bend right] (7);
\draw[v2] (7) -- (8);
\draw[v4] (8) -- (2,-1) -- (0);
\end{tikzpicture}
\end{document}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

您可以使用 amatrix或任何您想添加图例的内容

\documentclass[tikz,margin=3]{standalone}
\usetikzlibrary{shadows,matrix} % Shadows for nodes
\begin{document}
\begin{tikzpicture}
\tikzset{% This is the style settings for nodes
    dep/.style={circle,minimum size=#1,fill=orange!20,draw=orange,
                general shadow={fill=gray!60,shadow xshift=1pt,shadow yshift=-1pt}},
    dep/.default=1cm,
    cli/.style={circle,minimum size=#1,fill=white,draw,
                general shadow={fill=gray!60,shadow xshift=1pt,shadow yshift=-1pt}},
    cli/.default=1cm,
    spl/.style={cli=#1,append after command={
                  node[circle,draw,dotted,
                       minimum size=1.5cm] at (\tikzlastnode.center) {}}},
    spl/.default=1cm,
    c1/.style={-stealth,very thick,red!80!black},
    v2/.style={-stealth,very thick,yellow!65!black},
    v4/.style={-stealth,very thick,purple!70!black}}
\begin{scope}[local bounding box=graph]
    \node[dep] (0) at (0,0) {0};
    \node[cli] (7) at (-1,-2) {7};
    \node[spl] (8) at (2,-2) {8};
    \draw[c1] (0) to[bend right] (7);
    \draw[v2] (7) -- (8);
    \draw[v4] (8) -- (2,-1) -- (0);
\end{scope}
\matrix[draw,anchor=north west,xshift=1ex,matrix of nodes,row sep=.5ex,
        column 2/.style={text width=2.5cm,align=left,anchor=center}] 
at (graph.north east) {
    \draw[c1] (-.5,0) -- (.5,0); & $C_1$\\
    \draw[v2] (-.5,0) -- (.5,0); & $V_2$\\
    \draw[v4] (-.5,0) -- (.5,0); & $V_4$\\
    \draw[dotted] circle (.25);  & Split Delivery\\
    \node[cli=.5cm] {};          & Cliente\\
    \node[dep=.5cm] {};          & Deposito\\
};
\end{tikzpicture}
\end{document}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

看来你对 Ti k Z 还不是很了解,那么TeX.SE 上的这个问题可能对你有用。