怎样才能绘制到下面的代码呢?

怎样才能绘制到下面的代码呢?

我有以下代码


\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{graphs}
\usetikzlibrary{graphs.standard}
\begin{document}
\begin{tikzpicture}
\begin{scope}[nodes={circle, draw,minimum size=1.8em}]
 \graph[empty nodes] { 
  {subgraph I_n [n=12,radius=2.1cm, counterclockwise,phase=105] -- 
    x[label={[draw,minimum size=1em]center:{0}}]}; 
  1-- 2, 5-- 6, 7--8, 11 -- 12};
 \path (-{5*cos(40)},0) node (L){} ({5*cos(40)},0) node (R){}; % C4
\end{scope}
\draw (3) node{$a$}-- node[auto,swap]{$e$}(L) node{$b$} -- (4) node{$c$} (9) -- (R) -- (10);


\draw (1) node{$1$};
\draw (2) node{$2$};
\draw (3) node{$3$};
\draw (4) node{$4$};
\draw (5) node{$5$};

\draw (6) node{$6$};
\draw (7) node{$7$};
\draw (8) node{$8$};
\draw (9) node{$9$};
\draw (10) node{$10$};

\draw (11) node{$11$};
\draw (12) node{$12$};

\draw (R) node {$77$};


\draw[-] (1)  node[below] {$30$} (2);
%\path (node{$1$}) -- node[auto]{<g>} (node{$2$});

\end{tikzpicture}
\end{document}

答案1

这个答案之所以使用这个empty nodes键,是因为您展示了一个带有空节点的屏幕截图。如果您想填写数字,删除这个键比手动填充节点要容易得多。此外,如果您开始工业化生产边缘标签,这会很方便quotes。1

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{graphs,graphs.standard,quotes}
\begin{document}
\begin{tikzpicture}
\begin{scope}[nodes={circle, draw,minimum size=1.8em}]
 \graph { 
  {subgraph I_n [n=12,radius=2.1cm, counterclockwise,phase=105] -- 
    0}; 
  1-- 2, 5-- 6, 7--8, 11 -- 12};
 \path (-{5*cos(40)},0) node (L){} ({5*cos(40)},0) node (R){77}; % C4
\end{scope}
\draw[swap] (3) to["$e$" ](L)  to["$f$"](4) 
(9) to["$g$"] (R) to["$h$"] (10)
(1)  to["$30$" {pos=0.3}] (2);
\end{tikzpicture}
\end{document}

在此处输入图片描述

附录:也许更详细的解决方案可以让您更轻松地获得想要的东西。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}[auto,c/.style={circle, draw,minimum size=1.8em},
    every edge quotes={font=\small,draw=none,}]
 \path node[c](0) {$0$}
  foreach \X [count=\Y] in {20,19,10,12,15,18,13,17,8,7,16,14}
 {(75+\Y*30:3) node[c](\X) {$\X$} edge["$\X$" {pos=0.3}] (0)}
 (20) edge["1"](19) (14) edge["2"](16)
 (15) edge["3"](18) (13) edge["4"](17)
 ({-6*cos(15)},0) node[c] (1){$1$} ({6*cos(15)},0) node[c] (2){$2$}
 (1) edge["9"](10) (1) edge["11"](12)
 (2) edge["5"](7) (2) edge["6"](8);
\end{tikzpicture}
\end{document}

在此处输入图片描述

1但请注意,如果您使用该babel包,则可能需要加载 Ti同名的 Z 库也是如此。

相关内容