How to draw a broken/infinite hexagon in TikZ

Instead of producing a hexagon, I'd make a septagon where I don't draw one of the nodes.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt}]
  \foreach \l [count=\n] in {0,1,2,3,{},n-2,n-1} {
    \pgfmathsetmacro\angle{90-360/7*(\n-1)}
    \ifnum\n=5
      \coordinate (n\n) at (\angle:1);
    \else
      \node[dot,label={\angle:$\l$}] (n\n) at (\angle:1) {};
    \fi
  }
  \draw (n6) -- (n7) -- (n1) -- (n2) -- (n3) -- (n4);
  \draw[dashed,shorten >=5pt] (n4) -- (n5);
  \draw[dashed,shorten >=5pt] (n6) -- (n5);
\end{tikzpicture}

\end{document}

enter image description here


I would probably try something like this.

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \X/\Y [count=\Z] in {-60/3,-10/2,40/1,90/0,140/{$n-1$},190/{$n-2$}}
{\path (0,0) -- (\X:2.5) coordinate[pos=0.75] (C\Z)
node[anchor={180+\X},pos=0.85]{\Y};
\fill (C\Z) circle (2pt);}
\foreach \X [count=\Y] in {2,...,6}
{\draw (C\X) -- (C\Y);}
\draw[dashed,thick, shorten >=0.6cm] (-60:{2.5*0.75}) -- (-110:{2.5*0.75}); 
\draw[dashed,thick, shorten >=0.6cm] (-170:{2.5*0.75}) -- (-120:{2.5*0.75}) ;
\end{tikzpicture}
\end{document}

enter image description here

UPDATE: Fixed an error reported by Henri Menke and also made the thing more similar to the OP's picture.


Here is a solution using a "regular heptagon" node.

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{shapes.geometric}
\tikzset{
  heptagon/.style={
    shape=regular polygon, regular polygon sides=7,
    outer sep=0, minimum size=3cm, rotate=4*360/7,
    draw, dashed
  }
}
\begin{document}
  \begin{tikzpicture}
    \draw node[heptagon](H){} (H.corner 1)
      foreach[count=\i] \x in {3,...,0,n-2,n-1}{--(H.corner \i) node[scale=3]{.}[scale=1.3]node{\x}};
    \fill[white] (H.corner 7) circle(.4);
  \end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf