4

I want to draw the following graph by using the usepackage tkz-graph and the command foreach or by any other method: enter image description here

\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage{xcolor}
\usepackage{tkz-graph}

\begin{document}

\begin{tikzpicture}[rotate=-90]
\GraphInit[vstyle=Classic]
\SetVertexNoLabel
\SetGraphUnit{1.5}
\tikzset{VertexStyle/.append style={fill=black, minimum size=7pt, inner sep=1pt}}
\Vertex{a}
\SOEA(a){b}
\NOEA(a){c}
\EA(b){d}
\EA(c){e}
\Edges(b,d,e,c,a,b,c,e,b)  
\Edges(e,a,d,c)  
\end{tikzpicture}

\end{document}
5

Solution with vanilla tikz

\documentclass[border = 5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[
    node style/.style = {fill = black, minimum size = 7pt, circle},
    edge style/.style = {black, thick},
  ]

  % base
  \foreach \i in {0,...,4} {
    \node[node style] (A\i) at ({2 * cos(72 * \i)}, {2 * sin(72 * \i)}) {};
  }

  % blocks
  \foreach \i [evaluate=\j as \j using {int(Mod(\i + 1, 5))}] in {0,...,4} {

    % nodes, each block has nodes (A, B, C, D, E)
    \node[node style] (C\i) at ($ (A\i)!2cm!-90:(A\j) $) {};
    \node[node style] (D\i) at ($ (A\j)!2cm!90:(A\i) $) {};
    \coordinate (T\i) at ($ (C\i)!0.5!(D\i) $);
    \node[node style] (E\i) at ($ (T\i)!1.5cm!-90:(D\i) $) {};

    % edges
    \draw[edge style] (A\i) -- (A\j) -- (C\i) -- (D\i) -- (A\i)
    -- (C\i) -- (E\i) -- (D\i) -- (A\j) (A\i) -- (E\i) -- (A\j);

  }
\end{tikzpicture}

\end{document}

enter image description here

4

Solution based on your graph and with \foreach.

\documentclass{article}
\usepackage{amssymb,amsmath}
\usepackage{xcolor}
\usepackage{tkz-graph}

\begin{document}
\tikzset{pics/.cd,
house/.style={code={
\Vertex{a}
\SOEA(a){b}
\NOEA(a){c}
\EA(b){d}
\EA(c){e}
\Edges(b,d,e,c,a,b,c,e,b)  
\Edges(e,a,d,c)}}}
\begin{tikzpicture}
\GraphInit[vstyle=Classic]
\SetVertexNoLabel
\SetGraphUnit{1.5}
\tikzset{VertexStyle/.append style={fill=black, minimum size=7pt, inner sep=1pt}}
\foreach \X in {0,72,...,288}
{\path (\X-18:2.1) pic[rotate around={\X+180-18:(3,0)}] {house};}
\end{tikzpicture}
\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.