2

I am attempting to generate the following graph. who draw graphs?

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\def\r{4pt}
\def\dy{1cm}
\tikzstyle{c}=[draw,circle,fill=black,minimum size=\r,inner sep=0pt, anchor=center]
\tikzstyle{d}=[draw,circle,fill=white,minimum size=\r,inner sep=0pt, anchor=center]

\begin{tikzpicture}[font=\tiny]
  \draw (0,0)
    node [d] (C0) {}
    foreach \i in {1}
      {
        -- (0,\dy+\r) node (C\i) [d] {}
      };
  \draw (C1) ++(\dy+\r,0)
    node (C2) [d] {}
    foreach \i in {3}
      {
        -- (\dy+\r,0) node (C\i) [d] {}
      } 
     -- (C0) 
     (C1) -- (C2);
\end{tikzpicture}
\end{document}

enter image description here

3

enter image description here

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\begin{document}

\def\r{4pt}
\def\dy{1cm}
\tikzset{c/.style={draw,circle,fill=black,minimum size=\r,inner sep=0pt,
anchor=center},
d/.style={draw,circle,fill=white,minimum size=\r,inner sep=0pt, anchor=center}}

\begin{tikzpicture}[font=\tiny]
\pgfmathtruncatemacro{\Ncorners}{3}
\node[draw, regular polygon,regular polygon sides=\Ncorners,minimum size=3cm] 
(poly\Ncorners) {};
\node[regular polygon,regular polygon sides=\Ncorners,minimum size=4.5cm] 
(outerpoly\Ncorners) {};
\foreach\x in {1,...,\Ncorners}{
    \node[d] (poly\Ncorners-\x) at (poly\Ncorners.corner \x){};
    \node[d] (outerpoly\Ncorners-\x) at (outerpoly\Ncorners.corner \x){};
    \draw (poly\Ncorners-\x) -- (outerpoly\Ncorners-\x);
}
\begin{scope}[xshift=5cm]
\pgfmathtruncatemacro{\Ncorners}{4}
\node[draw, regular polygon,regular polygon sides=\Ncorners,minimum size=3cm] 
(poly\Ncorners) {};
\node[regular polygon,regular polygon sides=\Ncorners,minimum size=4.5cm] 
(outerpoly\Ncorners) {};
\foreach\x in {1,...,\Ncorners}{
    \node[d] (poly\Ncorners-\x) at (poly\Ncorners.corner \x){};
    \node[d] (outerpoly\Ncorners-\x) at (outerpoly\Ncorners.corner \x){};
    \draw (poly\Ncorners-\x) -- (outerpoly\Ncorners-\x);
}
\end{scope}
\begin{scope}[xshift=10cm]
\pgfmathtruncatemacro{\Ncorners}{5}
\node[draw, regular polygon,regular polygon sides=\Ncorners,minimum size=3cm] 
(poly\Ncorners) {};
\node[regular polygon,regular polygon sides=\Ncorners,minimum size=4.5cm] 
(outerpoly\Ncorners) {};
\foreach\x in {1,...,\Ncorners}{
    \node[d] (poly\Ncorners-\x) at (poly\Ncorners.corner \x){};
    \node[d] (outerpoly\Ncorners-\x) at (outerpoly\Ncorners.corner \x){};
    \draw (poly\Ncorners-\x) -- (outerpoly\Ncorners-\x);
}
\end{scope}
\end{tikzpicture}
\end{document}

I used the opportunity to replace \tikzstyle by \tikzset.

6

Just for fun, a single command code (only one ;).

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
  \tikz[
    poly/.style={regular polygon,minimum size=3cm},
    dot/.style={circle,inner sep=2pt,draw,fill=white}]
    \foreach \N in {3,4,5}
      \draw[regular polygon sides=\N,xshift=\N*7cm]
        node[poly,draw](S){} node[poly,scale=1.5](T){}
        foreach\i in{1,...,\N}{(S.corner \i) node[dot]{} -- (T.corner \i) node[dot]{}};
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.