帮助改进 tikz graph

帮助改进 tikz graph
 \documentclass{beamer}
    \mode<presentation>
    {
       \usetheme[secheader]{Madrid}
       \useoutertheme{Smoothbars}
       \usefonttheme[onlylarge]{structurebold}
       \setbeamerfont*{frametitle}{size=\normalsize,series=\bfseries} 
       \usefonttheme{professionalfonts}
    }
    \subject{...}
    \AtBeginSubsection[]
    {
        \begin{frame}<beamer>
            \frametitle{Plan wyk?du}
            \tableofcontents[currentsection,currentsubsection]
        \end{frame}
    }

    \newtheorem{thm}{Theorem}[section]
    \setbeamertemplate{theorem begin}
    {%
      \par\vskip\medskipamount%
      \begin{beamercolorbox}[colsep*=.75ex]{block title}
        \usebeamerfont*{block title}%
          \inserttheoremname
          \ifx\inserttheoremaddition\empty\else\ (\inserttheoremaddition)\fi%
      \end{beamercolorbox}%
      {\parskip0pt\par}%
      \ifbeamercolorempty[bg]{block title}
      {}
      {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
      \usebeamerfont{block body}%
      \vskip-.25ex\vbox{}%
    }
    \setbeamertemplate{theorem end}{}
    \usepackage{lipsum}
    \usepackage{mathrsfs,amsmath}
    \usepackage{mathrsfs}
    \usepackage{hyperref}
    \usepackage[english]{babel}
    \usepackage{times}
    \usepackage[T1]{fontenc}
    \usepackage{amsmath}
    \usepackage{amssymb}
    \usepackage[T1]{fontenc}
    \usepackage{amsthm}
    \usepackage{graphicx}
    \usepackage{pdflscape}
    \theoremstyle{definition}
    \newtheorem{defn}{Definition}[section]
    \theoremstyle{remark}
    \theoremstyle{plain}
    \newtheorem{lem}[thm]{Lemma}
    \newtheorem{cor}[thm]{Corollary}
    \newtheorem{rmk}[thm]{Remark}
    \newtheorem{prop}[thm]{Proposition}
    \newtheorem{conj}[thm]{Conjecture}
    \renewcommand{\thethm}{\thesection.\arabic{thm}}
    \renewcommand{\thelem}{\thesection.\arabic{lem}}
    \renewcommand{\thecor}{\thesection.\arabic{cor}}
    \renewcommand{\thermk}{\thesection.\arabic{rmk}}
    \renewcommand{\theprop}{\thesection.\arabic{prop}}
    \renewcommand{\theconj}{\thesection.\arabic{conj}}
    \renewcommand{\theequation}{\thesection.\arabic{equation}}
    \renewcommand{\thefootnote}{\fnsymbol{footnote}}
    \usepackage{verbatim}
    \usepackage{
    %graphicx,
    caption,subcaption}
    \newcommand{\noi}{\noindent}
    \allowdisplaybreaks
    \usepackage{tikz}
    %\usepackage{xcolor}
    \usetikzlibrary{intersections,arrows.meta,automata,er,calc,backgrounds,mindmap,folding,patterns,decorations.markings,fit,
    %snakes,
    shapes,matrix,positioning,shapes.geometric,through,arrows,decorations}

    \newcommand{\vertex}{\node[vertex]}
    \newcounter{Angle}


    \definecolor{myblue}{rgb}{24,40,120}
    \begin{document}
    \begin{frame}
    \begin{tikzpicture}[scale=0.35]
\tikzstyle{every node}= [shape=circle, draw,  
                     minimum size=2.4em, inner sep=2pt
                        ]
       \node (v0) [fill=brown] at (0:9) {$V_0$};
        \node (v1) [fill=red] at (18:9) {$V_1$};
        \node (v2) [fill=magenta] at (2*18:9) {$V_2$};
        \node (v3)  [fill=blue] at (3*18:9) {$V_3$};
        \node (v4) [fill=brown] at (4*18:9) {$V_4$};
        \node (v5) [fill=green] at (5*18:9) {$V_5$};
        \node (v6) [fill=magenta] at (6*18:9) {$V_6$};
        \node (v7) [fill=brown] at (7*18:9) {$V_7$};
        \node (v8) [fill=teal] at (8*18:9) {$V_8$};
        \node (v9) [fill=magenta] at (9*18:9) {$V_9$};
        \node (v10) [fill=pink] at (10*18:9) {$V_{10}$};
        \node (v11) [fill=blue] at (11*18:9) {$V_{11}$};
        \node (v12) [fill=olive] at (12*18:9) {$V_{12}$};
        \node (v13) [fill=green] at (13*18:9) {$V_{13}$};
                \node (v14) [fill=pink] at (14*18:9) {$V_{14}$};
        \node (v15) [fill=red] at (15*18:9) {$V_{15}$};
        \node (v16) [fill=blue] at (16*18:9) {$V_{16}$};
        \node (v17) [fill=green] at (17*18:9) {$V_{17}$};
        \node (v18) [fill=red] at (18*18:9) {$V_{18}$};
        \node (v19) [fill=olive] at (19*18:9) {$V_{19}$};
        \node (v20) [fill=teal] at (0,0) {$V_{20}$};


                \draw (v0) -- (v1) 
                (v1) -- (v2)
                (v2) -- (v3)
                (v3) --(v4)
                (v4) --(v5)
                (v5) --(v6)
                (v6) --(v7)
                (v7) -- (v8) 
                (v8) -- (v9)
                (v9) -- (v10)
                (v10) --(v11)
                (v11) --(v12)
                (v12) --(v13)
                (v13) --(v14)
                 (v14) --(v15)
                (v15) --(v16)
                (v16) --(v17)
                (v17) --(v18)
                (v17) --(v18)
                (v18) --(v19)
                (v19) --(v0)
                (v20) --(v10)
                 (v20) --(v11)
                (v20) --(v12)
                 (v20) --(v13)
                (v20) --(v14)
                                (v20) --(v15)
                                (v20) --(v16)
                                (v20) --(v17)
                                (v20) --(v18)
                                (v20) --(v19); 
    \end{tikzpicture}


    \end{frame}

    \end{document}

答案1

你能解释一下你想要实现什么吗?“更好”可以有很多含义。我猜你不希望节点重叠,至少我会称之为“更好”。

\documentclass{beamer}
\mode<presentation>
{
   \usetheme[secheader]{Madrid}
%   \useoutertheme{Smoothbars}
   \usefonttheme[onlylarge]{structurebold}
   \setbeamerfont*{frametitle}{size=\normalsize,series=\bfseries} 
   \usefonttheme{professionalfonts}
}
\subject{...}
\AtBeginSubsection[]
{
    \begin{frame}<beamer>
        \frametitle{Plan wyk?du}
        \tableofcontents[currentsection,currentsubsection]
    \end{frame}
}

\newtheorem{thm}{Theorem}[section]
\setbeamertemplate{theorem begin}
{%
  \par\vskip\medskipamount%
  \begin{beamercolorbox}[colsep*=.75ex]{block title}
    \usebeamerfont*{block title}%
      \inserttheoremname
      \ifx\inserttheoremaddition\empty\else\ (\inserttheoremaddition)\fi%
  \end{beamercolorbox}%
  {\parskip0pt\par}%
  \ifbeamercolorempty[bg]{block title}
  {}
  {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \usebeamerfont{block body}%
  \vskip-.25ex\vbox{}%
}
\setbeamertemplate{theorem end}{}
\usepackage{lipsum}
\usepackage{mathrsfs,amsmath}
\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{pdflscape}
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\theoremstyle{remark}
\theoremstyle{plain}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{rmk}[thm]{Remark}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{conj}[thm]{Conjecture}
\renewcommand{\thethm}{\thesection.\arabic{thm}}
\renewcommand{\thelem}{\thesection.\arabic{lem}}
\renewcommand{\thecor}{\thesection.\arabic{cor}}
\renewcommand{\thermk}{\thesection.\arabic{rmk}}
\renewcommand{\theprop}{\thesection.\arabic{prop}}
\renewcommand{\theconj}{\thesection.\arabic{conj}}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\usepackage{verbatim}
\usepackage{
%graphicx,
caption,subcaption}
\newcommand{\noi}{\noindent}
\allowdisplaybreaks
\usepackage{tikz}
%\usepackage{xcolor}
\usetikzlibrary{intersections,arrows.meta,automata,er,calc,backgrounds,mindmap,folding,patterns,decorations.markings,fit,
%snakes,
shapes,matrix,positioning,shapes.geometric,through,arrows,decorations}

\newcommand{\vertex}{\node[vertex]}
\newcounter{Angle}


\definecolor{myblue}{rgb}{24,40,120}
\begin{document}
\begin{frame}
\begin{tikzpicture}[scale=0.35]
    \tikzset{every node/.append style={draw,shape=circle,inner sep=1pt}};
    \node (v0) at (0:9) {$V_0$};
        \node (v1) at (18:9) {$V_1$};
        \node (v2)  at (2*18:9) {$V_2$};
        \node (v3) at (3*18:9) {$V_3$};
        \node (v4) at (4*18:9) {$V_4$};
        \node (v5) at (5*18:9) {$V_5$};
        \node (v6) at (6*18:9) {$V_6$};
        \node (v7) at (7*18:9) {$V_7$};
        \node (v8)at (8*18:9) {$V_8$};
        \node (v9) at (9*18:9) {$V_9$};
        \node (v10) at (10*18:9) {$V_{10}$};
        \node (v11) at (11*18:9) {$V_{11}$};
        \node (v12) at (12*18:9) {$V_{12}$};
        \node (v13) at (13*18:9) {$V_{13}$};
                \node (v14) at (14*18:9) {$V_{14}$};
        \node (v15) at (15*18:9) {$V_{15}$};
        \node (v16) at (16*18:9) {$V_{16}$};
        \node (v17) at (17*18:9) {$V_{17}$};
        \node (v18) at (18*18:9) {$V_{18}$};
        \node (v19) at (19*18:9) {$V_{19}$};
        \node (v20) at (0,0) {$V_{20}$};


                \draw (v0) -- (v1) 
                (v1) -- (v2)
                (v2) -- (v3)
                (v3) --(v4)
                (v4) --(v5)
                (v5) --(v6)
                (v6) --(v7)
                (v7) -- (v8) 
                (v8) -- (v9)
                (v9) -- (v10)
                (v10) --(v11)
                (v11) --(v12)
                (v12) --(v13)
                (v13) --(v14)
                                (v14) --(v15)
                (v15) --(v16)
                (v16) --(v17)
                (v17) --(v18)
                                (v17) --(v18)
                (v18) --(v19)
                                (v19) --(v0)
                (v20) --(v10)
                                (v20) --(v11)
                (v20) --(v12)
                                (v20) --(v13)
                (v20) --(v14)
                                (v20) --(v15)
                                (v20) --(v16)
                                (v20) --(v17)
                                (v20) --(v18)
                                (v20) --(v19); 
    \end{tikzpicture}


\end{frame}

\end{document}

在此处输入图片描述

答案2

目前还不完全清楚您的图像应该是什么样子。如 @marmot 在他的回答中所示 (+1)?如果是这种情况,并且在编辑您的文档示例后,似乎以下解决方案应该适合您:

\documentclass{beamer}
\usepackage{tikz}

\begin{frame}[fragile]
\tikzset{circ/.style = {shape=circle, draw, fill=#1,
                     minimum size=2em, inner sep=1pt,
                     transform shape}
        }
    \begin{tikzpicture}
\draw (0,0) circle[radius=3];
    \foreach \i [count=\j from 0] in {  
            brown,  red,        magenta,    blue,   brown,
            green,  magenta,    brown,      teal,   magenta,
            pink,   blue,       olive,      green,  pink,
            red,    blue,       green,      red,    olive}
    \draw (0,0) -- (\j*18:3) node[circ=\i] {$V_{\j}$};
\node[circ=teal] {$V_{20}$};
    \end{tikzpicture}
or 
    \begin{tikzpicture}[scale=0.5]
\draw (0,0) circle[radius=3];
    \foreach \i [count=\j from 0] in {
            brown,  red,        magenta,    blue,   brown,
            green,  magenta,    brown,      teal,   magenta,
            pink,   blue,       olive,      green,  pink,
            red,    blue,       green,      red,    olive}
    \draw (0,0) -- (\j*18:3) node[circ=\i] {$V_{\j}$};
\node[circ=teal] {$V_{20}$};
    \end{tikzpicture}
\end{frame}
\end{document} 

如您所见,除 之外的所有节点SV_{20}$均在循环中绘制,并附有连接线和填充颜色选项。结果是(左边是原始大小,右边是scale=0.5

在此处输入图片描述

相关内容