2

Based on draw pentagon graph and labels by marmot (Edit Manuel Kuehner)

I want to be drawn diagonally from all nodes in the same way as an image.

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\begin{document}

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

\begin{tikzpicture}

\pgfmathtruncatemacro{\Ncorners}{5}
\node[regular polygon,regular polygon sides=\Ncorners,minimum size=2cm] 
(poly\Ncorners) {};
\node[draw,regular polygon,regular polygon sides=\Ncorners,minimum size=4cm] 
(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);
}

\foreach\X in {1,...,\Ncorners}{
\foreach\Y in {1,...,\Ncorners}{
\pgfmathtruncatemacro{\Z}{abs(mod(abs(\Ncorners+\X-\Y),\Ncorners)-2)}
\ifnum\Z=0
\draw (poly\Ncorners-\X) -- (poly\Ncorners-\Y);
\fi
}
}
\node at (0,-2) {$G^2$};
\end{tikzpicture}
\end{document}

Example figure: enter image description here

  • 6
    It is good habit to cite your sources. – Kpym May 19 '18 at 9:27
  • Thanks, Yes it is. But this seems to me different. Because in addition to the lines drawn, a line must be drawn from all external nodes to the inner nodes as well as to other nodes. – H.Gorbanzad May 19 '18 at 10:15
  • Someone has voted to close your question as "unclear what you are asking". While I voted not to close the question for now, I at least partially agree that the question is a bit unclear. Do you want to only draw the additional lines/curves or do you want more? Is it always the same node, or do you want that to be customisable? – moewe May 19 '18 at 10:42
  • For the moment, I have the same shape and I want to have all the nodes together. And, for example, the edge from the upper node to the bottom is connected to the curve, so that it does not pass through the middle node. If it's not understandable, it's more for non-English speaking than being a servant. – H.Gorbanzad May 19 '18 at 11:42
  • 1
    @Kpym I edited the question accordingly. – Dr. Manuel Kuehner May 19 '18 at 13:04
2

I am also not sure if I understand what you are asking. So perhaps it is the simplest thing if I post something that might be it and you tell me what else should be done.

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\begin{document}

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

\begin{tikzpicture}

\pgfmathtruncatemacro{\Ncorners}{5}
\node[regular polygon,regular polygon sides=\Ncorners,minimum size=2cm] 
(poly\Ncorners) {};
\node[draw,regular polygon,regular polygon sides=\Ncorners,minimum size=4cm] 
(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);
}

\foreach\X in {1,...,\Ncorners}{
\foreach\Y in {1,...,\Ncorners}{
\pgfmathtruncatemacro{\Z}{abs(mod(abs(\Ncorners+\X-\Y),\Ncorners)-2)}
\ifnum\Z=0
\draw (poly\Ncorners-\X) to (poly\Ncorners-\Y);
\draw (outerpoly\Ncorners-\X) to[bend left=15] (poly\Ncorners-\Y);
\draw (outerpoly\Ncorners-\X) to[bend left=30] (outerpoly\Ncorners-\Y);
\fi
\pgfmathtruncatemacro{\Z}{abs(mod(abs(\Ncorners+\X-\Y),\Ncorners)-1)}
\ifnum\Z=0
\draw (outerpoly\Ncorners-\X) to[bend left=15] (poly\Ncorners-\Y);
\fi
}
}
\end{tikzpicture}
\end{document}

enter image description here

  • I think that the question was simply how to draw something like \draw (outerpoly5-1) to[bend left=15] (poly5-5);. – Kpym May 19 '18 at 13:55
  • @Kpym Merci. But I am not sure, there is an "all" in "I want to be drawn diagonally from all nodes in the same way as an image.". The simplest option would be if the OP told us. – marmot May 19 '18 at 14:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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