0

I'm trying to draw the graph $K_{3,3}$ and put the nodes in a circular placement where the nodes coordinates lie in the unit circle, by using Tkiz package.

Here is my current code:

\begin{tikzpicture}
\begin{scope}[shift={(3,0.7)}]
  \graph { subgraph K_nm [clockwise,nodes={draw,inner sep=0.1pt, fill=blue, circle, scale=0.6},n=3,m=3]};
\end{scope}
\end{tikzpicture}

But I get the following strange picture:

enter image description here

And I want to draw something like this layout:

enter image description here

  • Welcome! Please provide a complete example we can compile. Please also say how the output differs from what you want. – cfr Sep 23 '17 at 0:13
  • You have both n and m as 3. Don't you want one of them to be 2? Don't know if that's what you don't like, though. – cfr Sep 23 '17 at 0:14
  • You are right it supposed to be n=3,m=3. But this is not what makes the different that I'm wishing for. I will soon upload an good output example. – user1387682 Sep 23 '17 at 9:34
  • Please can you also complete your code so it is compilable? – cfr Sep 23 '17 at 12:33
3

Please post complete code. I spent longer figuring out how to reproduce the original image than how to produce the new one. You obviously know the manual has the library call wrong, else it wouldn't work for you either, so why not make it easy for people to help you and provide the required preamble?

Like this, possibly?

possible graph

\RequirePackage{luatex85}
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing,graphs.standard}
\begin{document}
\begin{tikzpicture}
  \begin{scope}[shift={(3,0.7)}]
    \graph [simple] { 
      subgraph K_n [n=6, clockwise, nodes={draw, inner sep=0.1pt, fill=blue, circle}];
      {1,2,3} --[induced complete bipartite] {4,5,6}
    };
  \end{scope}
\end{tikzpicture}
\end{document}
2

Just for comparison, here is k33 in Metapost, first in the conventional layout, then in a circular layout.

enter image description here

In MP there is no special syntax for graphs: once you have mastered defining points, drawing lines, filling paths, and the syntax for loops you can draw more or less anything using the same small set of syntax. Of course, if you want to, you can define your own macros to draw graphs.

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
    % some magic to make us the same vertical size as fig 2.
    undraw fullcircle scaled 120;
    undraw fullcircle scaled 12 shifted (point 6 of fullcircle scaled 120);
    drawarrow 60 right -- 72 right withcolor red;

    % define the nodes
    48 = -x1 = x3 = -x4 = x6;  x2 = x5 = 0;
    36 = y1 = y2 = y3 = -y4 = -y5 = -y6; 

    % connect them as per K_33
    for i=1 upto 3:
        for j = 1 upto 3:
            draw z[i] -- z[(i+j) mod 3 + 4];
        endfor
    endfor

    % mark each node
    for i=1 upto 6:
        fill fullcircle scaled 12 shifted z[i] withcolor 3/4[blue, white];
        draw fullcircle scaled 12 shifted z[i];
        label(decimal i, z[i]);
    endfor
endfig;
beginfig(2);

    % define the nodes on a circle this time
    for i=1 upto 6:
        z[i] = point 4 + 4/6 - 8/6 i of fullcircle scaled 120;
    endfor

    % the rest is the same
    for i=1 upto 3:
        for j = 1 upto 3:
            draw z[i] -- z[(i+j) mod 3 + 4];
        endfor
    endfor

    for i=1 upto 6:
        fill fullcircle scaled 12 shifted z[i] withcolor 3/4[blue, white];
        draw fullcircle scaled 12 shifted z[i];
        label(decimal i, z[i]);
    endfor
endfig;
\end{mplibcode}
\end{document}

This is wrapped up in luamplib so compile with lualatex. Or adapt for pdflatex with gmp, or for plain MP.

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.