我从 Al 机器人那里得到了这些代码,但它们有点拥挤。我需要编辑一下
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every node/.style={circle, draw, minimum size=1cm}]
\node (A) at (0,4) {Router 1};
\node (B) at (4,4) {Router 2};
\node (C) at (8,4) {Router 3};
\node (D) at (0,0) {Router 4};
\node (E) at (4,0) {Router 5};
\node (F) at (8,0) {Router 6};
\draw (A) -- (B) node[midway, above] {WAN Link 1};
\draw (B) -- (C) node[midway, above] {WAN Link 2};
\draw (A) -- (D) node[midway, left] {WAN Link 3};
\draw (B) -- (E) node[midway, below] {WAN Link 4};
\draw (C) -- (F) node[midway, right] {WAN Link 5};
\draw (D) -- (E) node[midway, below] {WAN Link 6};
\draw (E) -- (F) node[midway, below] {WAN Link 7};
\end{tikzpicture}
\end{document}
答案1
也许你正在寻找这样的东西:
- 请考虑收到的评论
- 一个(偷来的)代码片段,没有任何背景信息,而原始的完整代码试图呈现的这些信息对于提出问题来说并不是一个好的起点
- 在我的 MWE 中,我将路由器样式的节点与用于标记箭头的节点样式分开。
- 这个谜一样的答案对你有帮助吗?我们在读你的问题时也遇到过类似的情况……
好的,看来你喜欢结果和评论……这是你图表的改进代码。顺便说一句,不要太相信人工智能 :-)
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{quotes,
shadows}
\begin{document}
\begin{tikzpicture}[
every edge/.style = {draw=gray, line width=3pt},
every edge quotes/.style = {auto, font=\small, text width=3em, align=center},
R/.style = {circle, draw, text width=3.3em, align=center,
font=\bfseries, fill=white, drop shadow}
]
\begin{scope}[nodes=R]
\node (A) at (0,4) {Router 1};
\node (B) at (4,4) {Router 2};
\node (C) at (8,4) {Router 3};
\node (D) at (0,0) {Router 4};
\node (E) at (4,0) {Router 5};
\node (F) at (8,0) {Router 6};
\end{scope}%
\draw (A) edge["WAN Link 1"] (B)
(B) edge["WAN Link 2"] (C)
(A) edge["WAN Link 3"] (D)
(B) edge["WAN Link 4"] (E)
(C) edge["WAN Link 5"] (F)
(D) edge["WAN Link 6"] (E)
(E) edge["WAN Link 7"] (F);
\end{tikzpicture}
\end{document}