绘制共享边和顶点的连通完全子图

绘制共享边和顶点的连通完全子图

如何使用 TikZ 绘制以下图形 在此处输入图片描述 这是子图,但我不知道如何连接它们

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}

\begin{document}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         empty nodes, nodes={circle,draw}] { subgraph K_n [n=7,clockwise,radius=2cm] };
\end{tikzpicture}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         empty nodes, nodes={circle,draw}] { subgraph K_n [n=5,clockwise,radius=2cm] };
\end{tikzpicture}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         empty nodes, nodes={circle,draw}] { subgraph K_n [n=2] };
\end{tikzpicture}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         empty nodes, nodes={circle,draw}] { subgraph K_n [n=1] };
\end{tikzpicture}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         empty nodes, nodes={circle,draw}] { subgraph K_n [n=1] };
\end{tikzpicture}
\begin{tikzpicture}
  \graph[circular placement, radius=4cm,
         empty nodes, nodes={circle,draw}] { subgraph K_n [n=1] };
\end{tikzpicture}
\end{document} 

答案1

我确信这不是最好的,但不只是为我做 tikz这个问题值得一个答案。

\documentclass{article}
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, positioning, calc}
\tikzset{%
    mynode/.style={%
        circle, radius=2pt, draw=darkgray, fill=white
    }
}

\begin{document}
    \begin{tikzpicture}
    \node[minimum size=4cm, regular polygon, regular polygon sides=7, rotate=180] (epta) {};
    \foreach \x in {1,2,...,7}{%
        \node[mynode] at (epta.corner \x) (e\x) {};
    }
    \foreach \x in {1,2,...,7}{%
        \foreach \y in {1,2,...,7}{%
            \ifthenelse{\x>\y}{}{\draw[darkgray] (e\x) -- (e\y);}       
    }}
    \node[below= 2pt of e1] {$10$};
    \node[below= 2pt of e2] {$12$};
    \node[above right = 2pt and -1pt of e3] {$6$};
    \node[above right = 0pt and -1pt of e4] {$4$};
    \node[above left = 0pt and -1pt of e5] {$2$};
    \node[below left = 0pt and -1pt of e6] {$14$};
    \node[below left = 0pt and -1pt of e7] {$8$};
    \node(p1) at (e2) {};
    \node(p2) at (e3) {};
    \foreach \nextp/\prevp/\i in {p3/p2/1,p4/p3/2,p5/p4/3}{%
        \node[mynode] (\nextp) at ($(\prevp)+(77-\i*72:50pt)$) {};
    }    
    \foreach \x in {1,2,...,5}{%
        \foreach \y in {1,2,...,5}{%
            \ifthenelse{\x>\y}{}{\draw[darkgray] (p\x) -- (p\y);}       
    }}
    \node[above right = 2pt and -1pt of p3] {$9$};
    \node[right = 1pt of p4] {$3$};
    \node[below right = 2pt and 0pt of p5] {$15$};
    \node[mynode, below right = 40pt and 1pt of e2, label={[label distance=2pt]-90:$5$}] (s1) {};
    \draw[darkgray] (e1) -- (p5) -- (s1) -- (e1);
    \node[mynode, above left = 20pt and 40pt of e6, label={[label distance=2pt]-90:$7$}] (s2) {};
    \draw[darkgray] (s2) -- (e6);
    \node[mynode, below = 110pt of s2, label={[label distance=2pt]-90:$1$}] (s3) {};
    \node[mynode, right = 20pt of s3, label={[label distance=2pt]-90:$11$}] (s4) {};
    \node[mynode, right = 20pt of s4, label={[label distance=2pt]-90:$13$}] (s5) {};
    \node[above left = 50pt and 40pt of s3] {$G$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容