I want to draw in LaTex a Petersen Graph using Kneser graph K(2,5) notation. And i'll do the same with the hypercube. Like this exemple: How can i do it please ? enter image description here

  • Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – Stefan Pinnow May 20 '18 at 12:05

The labeling of this graph is based on the Kneser notation example in Wikipedia.


\tikzset{c/.style={draw,circle,fill=black,minimum size=4pt,inner sep=0pt,
d/.style={draw,circle,fill=white,minimum size=4pt,inner sep=0pt, anchor=center}}
% from https://tex.stackexchange.com/a/294254/121799
\def\colorlist{{"cyan", "red", "orange", "yellow", "green", "gray", "blue", "violet"}}

\node[regular polygon,regular polygon sides=\Ncorners,minimum size=3cm] 
(poly\Ncorners) {};
\node[draw,regular polygon,regular polygon sides=\Ncorners,minimum size=5cm] 
(outerpoly\Ncorners) {};
\foreach\x in {1,...,\Ncorners}{
    \node[d,label={{18+\x*72}:{$\{\myprevx,\mynextx\}$}},color=\myfill] (outerpoly\Ncorners-\x) at (outerpoly\Ncorners.corner \x){};
    \node[d,label={{\ang}:{$\{\myprevx,\mynextx\}$}},color=\myfill] (poly\Ncorners-\x) at (poly\Ncorners.corner \x){};
    \draw (poly\Ncorners-\x) -- (outerpoly\Ncorners-\x);
\foreach\X in {1,...,\Ncorners}{
\foreach\Y in {1,...,\Ncorners}{
\draw (poly\Ncorners-\X) -- (poly\Ncorners-\Y);

enter image description here

UPDATE: Colors.

  • Thank u, can i ask you for the coloring ? For exemple; red for {5,2},{3,2},{2,1},{2,4}, blue for {1,3}, {4,3}, {4,1}, and green for {5,4}, {1,5}, {3,5}. You're code is a little bit complicated for me, so i don't find how to do it. I used to do simple \node for vertex and \draw for bridges so... – Massyl Kaci May 20 '18 at 16:53
  • This code uses simple nodes for the vertices and draw for the bridges, but in a foreach loop and using the predefined corners of regular polygons. What do you want to have colored, vertices, texts, or both? And is there a mathematical pattern for the coloring, which can be implemented in the loop? – marmot May 20 '18 at 16:59
  • I work on the chromatic number, so i want to have the vertices minimal coloring, there are many alghorithms that gives this coloration. In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices share the same color. – Massyl Kaci May 20 '18 at 17:59
  • @MassylKaci Meaning that I can take the color according to the index of one of its neighbors? – marmot May 20 '18 at 18:04
  • But it's not the optimum, we only need 3 colors for the Petersen's graph, as i said color 1 for {5,2},{3,2},{2,1},{2,4}, color 2 for{1,3}, {4,3}, {4,1} color 3 for {5,4}, {1,5}, {3,5} – Massyl Kaci May 20 '18 at 19:39

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.