答案1
欢迎来到 TeX.SE!方向\WE
、\SO
等代表west
、south
等。这允许您根据需要进行垂直和水平连接。
\documentclass[border=10pt]{standalone}
%%%<
\usepackage{verbatim}
%%%>
\begin{comment}
:Title: Drawing a graph
:Tags: Graphs;Computer Science
:Author: Stefan Kottwitz
:Slug: graph
In graph theory, models and drawings often consists mostly
of vertices, edges, and labels. So, it may be possible,
to use a simpler language for generating a diagram of a graph.
The tkz-graph package offers a convenient interface.
The code is fully explained in the LaTeX Cookbook, Chapter 11,
Science and Technology, Application in graph theory.
\end{comment}
\usepackage{tkz-graph}
\GraphInit[vstyle = Shade]
\tikzset{
LabelStyle/.style = { rectangle, rounded corners, draw,
minimum width = 2em, fill = yellow!50,
text = red, font = \bfseries },
VertexStyle/.append style = { inner sep=5pt,
font = \Large\bfseries},
% EdgeStyle/.append style = { bend left}
}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}
\SetGraphUnit{3.5}
\Vertex{A}
\EA(A){B}
\EA(B){C}
\EA(C){D}
\EA(D){E}
\SO(A){F}
\SO(B){G}
\SO(D){H}
\SO(E){I}
\Edge[label = 1](A)(B)
\Edge[label = 2](B)(C)
\Edge[label = 3](C)(D)
\Edge[label = 4](D)(E)
\Edge[label = 5](A)(F)
\Edge[label = 6](B)(G)
\Edge[label = 7](D)(H)
\Edge[label = 8](E)(I)
\Edge[label = 9](F)(G)
\Edge[label = 10](H)(I)
\end{tikzpicture}
\end{document}