答案1
这是为了给你一个开始。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{gon/.style={name=tmp,regular polygon,regular polygon sides=#1,minimum
size=10pt,inner sep=0pt},
polygon side/.style args={#1--#2}{
insert path={(tmp.corner #1)-- (tmp.corner #2)}}}
\newcommand{\FlagGraph}[3][]{\ifnum#2=2%
\tikz[baseline=(tmp1)]{\node[circle,inner sep=0.7pt,fill] (tmp1) at (0,0){};
\node[#1,circle,inner sep=0.7pt,fill] (tmp2) at (0,10pt){};
\ifx#3\empty%
\else
\draw[#1] (tmp1) -- (tmp2);
\fi}
\else%
\tikz[baseline=(tmp.south)]{\node[#1,gon=#2]{};
\foreach \X in {1,...,#2}{\fill (tmp.corner \X) circle (1pt);}
\draw[#1,polygon side/.list={#3}]}
\fi}
\begin{document}
This answer comes with a command
\[ \texttt{\textbackslash FlagGraph}\{n\}\{\langle\texttt{connection}~1\rangle,
\langle\texttt{connection}~2\rangle,\dots\}\;,\]
where $n$ denotes the number of corners and the second argument is a list of
connections that are to be drawn.
These are some sample graphs: \FlagGraph{5}{1--2,1--4} \FlagGraph{3}{1--2} \FlagGraph{2}{1--2} \FlagGraph{2}{}
\FlagGraph{5}{3--1,3--2,3--4,3--5}
\end{document}