带节点的正多边形上的圆圈数

带节点的正多边形上的圆圈数

为了重现这样的事情,最好的方法是什么?在此处输入图片描述

答案1

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    % ----- style -----
    \tikzset{
        mynodestyle/.style={draw, circle, fill=white}
    }

    % ----- nodes -----
    \newcommand\n{6}
    \newcommand\radius{3cm}
    \edef\angleStep{\number\numexpr360/\n\relax}
    \foreach \lbl [count=\i from 0] in {1,...,\n} {
        \node[mynodestyle] (\lbl) at (180-\i*\angleStep:\radius) {\lbl};
    }
%   \foreach \this [remember=\this as \last (initially \n)] in {1,...,\n} {
%       \path (\last) edge (\this);
%   }
    \path (1) -- node[mynodestyle, pos=.4] (7) {7} (6);

    % ----- edges -----
    \path[auto]
        % outer
        (1) edge node {1} (2)
        (2) edge node {4} (3)
        (3) edge node {2} (4)
        (4) edge node {2} (5)
        (5) edge node {1} (6)
        (6) edge node {2} (7)
        (7) edge node {3} (1)
        % inner
        (1) edge node[pos=.7] {3} (5)
        (2) edge node {1} (7)
        (3) edge node {2} (6)
        (3) edge node {3} (5)
    ;
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您可以自定义颜色和线条。希望对您有所帮助。

在此处输入图片描述

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-5.20,-4.20) rectangle (6.93,7.72);
\fill [orange, draw=cyan](-4.,2.) circle (0.5cm);
\fill [magenta, draw=cyan](2.94,5.13) circle (0.5cm);
\fill [teal, draw=cyan](-1.5,5.16) circle (0.5cm);
\fill [cyan, draw=cyan](5.58,2.14) circle (0.5cm);
\fill [lime, draw=cyan](4.29,-1.93) circle (0.5cm);
\fill [pink, draw=cyan](-1.05,-2.82) circle (0.5cm);
\fill [red, draw=cyan] (-2.53,-0.53) circle (0.5cm);
\draw[ultra thick] (-3.74,1.57)-- (-2.74,-0.07);
\draw[ultra thick] (-2.27,-0.95)-- (-1.32,-2.40);
\draw[ultra thick] (-0.61,-3.04)-- (3.80,-2.05);
\draw[ultra thick] (4.42,-1.44)-- (3.1,4.67);
\draw[ultra thick] (5.46,2.630073247966307)-- (3.4,5.1);
\draw[ultra thick] (-0.77,-2.40)-- (2.5,4.90);
\draw[ultra thick] (-1.03,5.24)-- (2.5,5.4);
\draw[ultra thick] (-4.07,2.5)-- (-2,5);
\draw[ultra thick] (-2.17,-0.18)-- (-1.38,4.68);
\draw[ultra thick] (-3.50,2)-- (3.9,-1.59);
\draw[ultra thick] (4.72,-1.68)-- (5.5,1.65);
\draw(-1.28,-2.6) node[anchor=north west] {\Large $\textbf{6}$};
\draw (-2.76,-0.3) node[anchor=north west] {\Large $7$};
\draw (5.30,2.3) node[anchor=north west] {\Large $4$};
\draw (4.03,-1.7) node[anchor=north west] {\Large $5$};
\draw (2.69,5.4) node[anchor=north west] {\Large $3$};
\draw (-1.77,5.5) node[anchor=north west] {\Large $2$};
\draw (-4.28,2.34) node[anchor=north west] {\Large $1$};
\draw (0.67,6.12) node[anchor=north west] {\Large $4$};
\draw (4.9,4.39) node[anchor=north west] {\Large $2$};
\draw (5.37,0.32) node[anchor=north west] {\Large $2$};
\draw (3.9,2.5) node[anchor=north west] {\Large $3$};
\draw (1.7,-3) node[anchor=north west] {\Large $1$};
\draw (-2.55,-1.8) node[anchor=north west] {\Large $2$};
\draw (1.66,2.1) node[anchor=north west] {\Large $2$};
\draw (1.56,0.15) node[anchor=north west] {\Large $3$};
\draw (-1.49,2.91) node[anchor=north west] {\Large $1$};
\draw (-4,1) node[anchor=north west] {\Large $3$};
\draw (-3.5,4.2) node[anchor=north west] {\Large $1$};
\end{tikzpicture}
\end{document}

相关内容