使用LaTex绘制图形(图形理论)

时间:2018-11-27 10:27:51

标签: latex

我目前正在LaTex中撰写有关图论的文章,​​并且很好奇如何创建如下图: https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/(以我的老师为例)

1 个答案:

答案 0 :(得分:1)

TikZ是一个不错的LaTeX软件包,用于处理图形。以下是一些示例:http://www.texample.net/tikz/examples/tag/graphs/

我特别使用TikZ重新创建了您的图形。这是结果。 Graph producible by TikZ

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
      \tikzset{enclosed/.style={draw, circle, inner sep=0pt, minimum size=.15cm, fill=black}}

      \node[enclosed, label={left, yshift=.2cm: E}] (E) at (0.75,3.25) {};
      \node[enclosed, label={above, xshift=.2cm: H}] (H) at (3,4) {};
      \node[enclosed, label={right, yshift=0cm: B}] (B) at (4.5,2) {};
      \node[enclosed, label={below, xshift=.2cm: M}] (M) at (3,0) {};
      \node[enclosed, label={left, yshift=-.2cm: L}] (L) at (0.75,0.75) {};

      \draw (E) -- (H) node[midway, sloped, above] (edge1) { $\infty$};
      \draw (H) -- (B) node[midway, right] (edge2) {288};
      \draw (B) -- (M) node[midway, right] (edge3) {585};
      \draw (L) -- (M) node[midway, below] (edge4) {$\infty$};
      \draw (E) -- (L) node[midway, left] (edge5) {640};
      \draw (E) -- (B) node[midway, above] (edge6) {$\infty$};
      \draw (E) -- (M) node[midway, left] (edge7) {$\infty$};
      \draw (L) -- (H) node[midway, left] (edge8) {$\infty$};
      \draw (L) -- (B) node[midway, below] (edge9) {$\infty$};
      \draw (H) -- (M) node[midway, right] (edge10) {775};
\end{tikzpicture}
\end{document}