3

enter image description hereI have this hexagon generated by

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
    \begin{tikzpicture}
        \def\r{2}
        \foreach \c [count=\i from 0] in {
            $\overline{1}$,
            $\overline{3}$,
            $2$,
            $1$,
            $3$,
            $\overline{2}$}
            {
            \path (0,0) -- (60*\i:\r) node[circle,inner sep=1mm,fill=black](\i){} --++ (60*\i:10pt) node{\c};
            }
            \foreach \i in {0,...,5}
                \foreach \n in {\i,...,5}
                    \draw (\i.center) -- (\n.center);
    \end{tikzpicture}
\end{document}

for which I would like to turn the diameters determined by $(2,\overline{2})$, $(1,\overline{1})$ and $(3,\overline{3})$ red (as in the given image above). I am not sure how to do that. I would want the other edges in the graph to stay black. enter image description here

4

Like this:

enter image description here

Note: your code fragment doesn't produce showed image

You only need to separate drawing lines between vertices on the black and red part:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[
        dot/.style={circle,fill, inner sep=1.5pt},
every label/.style={inner sep=0pt}] 
\newdimen\R
\R=1.3cm
   \draw
    (60:\R) \foreach \x in {120,180,...,300} {  -- (\x:\R) };
   \draw[red]
    (300:\R) \foreach \x in {360,60} {  -- (\x:\R) };
   \foreach \i [count=\j] in { \overline{3},2,1,3,\overline{2},\overline{1} }
   {
        \node[dot, label=60*\j:$\i$] at (60*\j:\R) {};
   }
\end{tikzpicture}
\end{document}

Edit (1): or with interconnection between all vertices:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[
        dot/.style={circle,fill, inner sep=1.5pt, outer sep=0pt},
every label/.style={inner sep=0pt}] 
\newdimen\R
\R=1.3cm
\draw[red]
    (300:\R) \foreach \x in {360,60} {  -- (\x:\R) };
\foreach \i [count=\j] in { \overline{3},2,1,3,\overline{2},\overline{1} }
{
    \node (n\j) [dot, label=60*\j:$\i$] at (60*\j:\R) {};
}
\foreach \i in {1,...,4}
{
\ifnum\i=1
    \foreach \j in {2,...,5}
    \draw (n\i) -- (n\j);
\else
    \foreach \j in {\i,...,6}
    \draw (n\i) -- (n\j);
\fi
}
    \end{tikzpicture}
\end{document}

enter image description here

Edit (2): Image added in edited answer can be reproduced by:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}

\begin{document}
    \begin{tikzpicture}[
        dot/.style={circle,fill, inner sep=1.5pt, outer sep=0pt},
every label/.style={inner sep=0pt}] 
\newdimen\R \R=1.3cm

\foreach \i [count=\j] in { \overline{3},2,1,3,\overline{2},\overline{1} }
{
\node (n\j) [dot, label=60*\j:$\i$] at (60*\j:\R) {};
\draw[red,semithick]  (0,0) -- (n\j);
}

\scoped[on background layer]
{
\foreach \i in {1,2,...,6}
    \foreach \j in {\i,...,6}
    \draw (n\i) -- (n\j);
}
    \end{tikzpicture}
\end{document}

enter image description here

6
  • 1
    @Black Mild, thank you very much for correcting spelling errors! – Zarko Apr 18 at 6:53
  • I changed the code in the original post but I am still unsure how to do it. When I am drawing the red edges, how do I do it? Do I use 90 instead of 60? – causalityrefilm. Apr 18 at 7:06
  • @causalityrefilm., sorry, I do not understand your comment. My answer solve your problem as You describe it in question. In your images is angle of 90 degrees ... – Zarko Apr 18 at 7:10
  • I probably explained it unclearly. I added a picture in my question of what I want. – causalityrefilm. Apr 18 at 7:12
  • @causalityrefilm, image is quite different what you explain your problem Please also correct text in question, I will ad new solution ASAP. – Zarko Apr 18 at 7:17
3

Here is a TikZ way using syntax x ? y :z (meaning if x then y else z) and several \foreach commands.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\r{2}
\foreach \i in {1,...,6}
\path (\i*60:\r) coordinate (A\i);

\foreach \i in {1,...,6}
\foreach \j  in {\i,...,6}
{
\pgfmathparse{\j-\i-3 ? "black" : "red"}
\draw[\pgfmathresult] (A\i)--(A\j);
}

\foreach \i/\itext in {1/{\overline 3},2/2,3/1,4/3,5/{\overline 2},6/{\overline 1}}
\fill (A\i) circle(2pt) ++(\i*60:.3) node{$\itext$};
\end{tikzpicture}
\end{document}

Update an Asymptote translation

enter image description here

//http://asymptote.ualberta.ca/
unitsize(1cm);
real r=2;
pair[] A; 
for (int i=0; i<6; ++i) 
A[i]=r*dir(60*i); 

for (int i=0; i<5; ++i)
for (int j=i+1; j<6; ++j)
if (j-i==3) 
draw(A[i]--A[j],magenta);
else 
draw(A[i]--A[j],blue);

string[] vlabel={"$\overline 1$","$\overline 3$","2","1","3","$\overline 2$"};
for (int i=0; i<6; ++i){
fill(circle(A[i],.1),purple);
label(vlabel[i],A[i]+.35*dir(60*i));
}
shipout(bbox(5mm,invisible)); 
3
  • 3
    +1 Nice use of the x ? y : z syntax in this context. – SebGlav Apr 18 at 9:48
  • a Asymptote translation is added. – Black Mild Apr 19 at 10:55
  • @SebGlav thank you! – Black Mild Apr 19 at 10:55

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.