TikZ graph edges not drawn nicelyHow to grey out edges in a tikz graph?Tikz Graph with Nodes and Edges and...

Treasure Hunt Riddle

How do you funnel food off a cutting board?

What language shall they sing in?

How to politely refuse in-office gym instructor for steroids and protein

What is a DAG (Graph Theory)?

How does one write from a minority culture? A question on cultural references

What will happen if Parliament votes "no" on each of the Brexit-related votes to be held on the 12th, 13th and 14th of March?

Why do neural networks need so many training examples to perform?

How can the probability of a fumble decrease linearly with more dice?

How do I prevent a homebrew Grappling Hook feature from trivializing Tomb of Annihilation?

Which RAF squadrons and aircraft types took part in the bombing of Berlin on the 25th of August 1940?

What happens when the wearer of a Shield of Missile Attraction is behind total cover?

The effect of fishing on total land area needed to feed an island settlement

How can I play a serial killer in a party of good PCs?

Early credit roll before the end of the film

Saint abbreviation

TikZ graph edges not drawn nicely

Why would space fleets be aligned?

Why did Democrats in the Senate oppose the Born-Alive Abortion Survivors Protection Act?

Airplane generations - how does it work?

Strange "DuckDuckGo dork" takes me to random website

Is a new boolean field better than null reference when a value can be meaningfully absent?

How would an AI self awareness kill switch work?

Why did the villain in the first Men in Black movie care about Earth's Cockroaches?



TikZ graph edges not drawn nicely


How to grey out edges in a tikz graph?Tikz Graph with Nodes and Edges and some DotsDrawing Tapered Edges in GraphHow to define the default vertical distance between nodes?TiKZ node name prefixes in scopesLine up nested tikz enviroments or how to get rid of themtikz: nodes overlapping with edges on graphEdges getting super small in Tikz Graph, apparent inheritance issue?tkz-graph: Edges works but not EdgeEdge not crossing other edges in a TikZ graph













1















I am still new to using Tikz... I am trying to draw a wheel-like graph using TikZ. I have the basic graph done, but it is not turning out how I expected it to. The edges in my graph aren't centered/lined up well.



The edges seem to be following the coordinates rather than drawing a shortest-path straight line between the nodes stopping at their circle representations. Some of the edges are fine (like v1 to v2, v1 to v6, ...) but some others aren't (like v2 to v3).



Here is my code for the TikZ picture, and an image showing what I am getting.



begin{tikzpicture}[auto, scale=0.9]
tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
node (v1) at (0,0) [vertex] {};
node (v2) at (1,0) [vertex] {};
node (v3) at (1.5,-1) [vertex] {};
node (v4) at (1,-2) [vertex] {};
node (v5) at (0,-2) [vertex] {};
node (v6) at (-.5,-1) [vertex] {};
node (v7) at (.5,-1) [vertex, fill=blue] {};

foreach x in {2, 3, 4, 5, 6, 7}{
pgfmathsetmacroy{x - 1}
draw (vy) to (vx);
}
draw (v6) to (v1);
draw (v5) to (v7);
draw (v4) to (v7);
draw (v3) to (v7);
end{tikzpicture}


wheel like graph with bad looking edges










share|improve this question







New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.

    – marmot
    3 hours ago
















1















I am still new to using Tikz... I am trying to draw a wheel-like graph using TikZ. I have the basic graph done, but it is not turning out how I expected it to. The edges in my graph aren't centered/lined up well.



The edges seem to be following the coordinates rather than drawing a shortest-path straight line between the nodes stopping at their circle representations. Some of the edges are fine (like v1 to v2, v1 to v6, ...) but some others aren't (like v2 to v3).



Here is my code for the TikZ picture, and an image showing what I am getting.



begin{tikzpicture}[auto, scale=0.9]
tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
node (v1) at (0,0) [vertex] {};
node (v2) at (1,0) [vertex] {};
node (v3) at (1.5,-1) [vertex] {};
node (v4) at (1,-2) [vertex] {};
node (v5) at (0,-2) [vertex] {};
node (v6) at (-.5,-1) [vertex] {};
node (v7) at (.5,-1) [vertex, fill=blue] {};

foreach x in {2, 3, 4, 5, 6, 7}{
pgfmathsetmacroy{x - 1}
draw (vy) to (vx);
}
draw (v6) to (v1);
draw (v5) to (v7);
draw (v4) to (v7);
draw (v3) to (v7);
end{tikzpicture}


wheel like graph with bad looking edges










share|improve this question







New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.

    – marmot
    3 hours ago














1












1








1








I am still new to using Tikz... I am trying to draw a wheel-like graph using TikZ. I have the basic graph done, but it is not turning out how I expected it to. The edges in my graph aren't centered/lined up well.



The edges seem to be following the coordinates rather than drawing a shortest-path straight line between the nodes stopping at their circle representations. Some of the edges are fine (like v1 to v2, v1 to v6, ...) but some others aren't (like v2 to v3).



Here is my code for the TikZ picture, and an image showing what I am getting.



begin{tikzpicture}[auto, scale=0.9]
tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
node (v1) at (0,0) [vertex] {};
node (v2) at (1,0) [vertex] {};
node (v3) at (1.5,-1) [vertex] {};
node (v4) at (1,-2) [vertex] {};
node (v5) at (0,-2) [vertex] {};
node (v6) at (-.5,-1) [vertex] {};
node (v7) at (.5,-1) [vertex, fill=blue] {};

foreach x in {2, 3, 4, 5, 6, 7}{
pgfmathsetmacroy{x - 1}
draw (vy) to (vx);
}
draw (v6) to (v1);
draw (v5) to (v7);
draw (v4) to (v7);
draw (v3) to (v7);
end{tikzpicture}


wheel like graph with bad looking edges










share|improve this question







New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I am still new to using Tikz... I am trying to draw a wheel-like graph using TikZ. I have the basic graph done, but it is not turning out how I expected it to. The edges in my graph aren't centered/lined up well.



The edges seem to be following the coordinates rather than drawing a shortest-path straight line between the nodes stopping at their circle representations. Some of the edges are fine (like v1 to v2, v1 to v6, ...) but some others aren't (like v2 to v3).



Here is my code for the TikZ picture, and an image showing what I am getting.



begin{tikzpicture}[auto, scale=0.9]
tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
node (v1) at (0,0) [vertex] {};
node (v2) at (1,0) [vertex] {};
node (v3) at (1.5,-1) [vertex] {};
node (v4) at (1,-2) [vertex] {};
node (v5) at (0,-2) [vertex] {};
node (v6) at (-.5,-1) [vertex] {};
node (v7) at (.5,-1) [vertex, fill=blue] {};

foreach x in {2, 3, 4, 5, 6, 7}{
pgfmathsetmacroy{x - 1}
draw (vy) to (vx);
}
draw (v6) to (v1);
draw (v5) to (v7);
draw (v4) to (v7);
draw (v3) to (v7);
end{tikzpicture}


wheel like graph with bad looking edges







tikz-pgf graphs






share|improve this question







New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









AbrahamAbraham

61




61




New contributor




Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Abraham is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • The issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.

    – marmot
    3 hours ago



















  • The issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.

    – marmot
    3 hours ago

















The issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.

– marmot
3 hours ago





The issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.

– marmot
3 hours ago










4 Answers
4






active

oldest

votes


















2














tikzstyle is deprecated and the issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.



documentclass[tikz,border=3.14mm]{standalone}
begin{document}
begin{tikzpicture}[auto, scale=0.9]
tikzset{vertex/.style={draw, circle, inner sep=0.55mm}}
node (v1) at (0,0) [vertex] {};
node (v2) at (1,0) [vertex] {};
node (v3) at (1.5,-1) [vertex] {};
node (v4) at (1,-2) [vertex] {};
node (v5) at (0,-2) [vertex] {};
node (v6) at (-.5,-1) [vertex] {};
node (v7) at (.5,-1) [vertex, fill=blue] {};

foreach x [remember =x as lastx (initially 1)] in {2, 3, 4, 5, 6, 7}{
draw (vlastx) to (vx);
}
draw (v6) to (v1);
draw (v5) to (v7);
draw (v4) to (v7);
draw (v3) to (v7);
end{tikzpicture}
end{document}


enter image description here






share|improve this answer































    2














    That's because the calculation of y doesn't give an integer. There are two possibilities:




    • the first is to use the macro pgfmathtruncatemacro instead of pgfmathsetmacro

    • the second is to evaluate y within the foreach loop itself




    documentclass[tikz,border=5mm]{standalone}

    usetikzlibrary{calc}

    begin{document}
    begin{tikzpicture}[auto, scale=0.9]
    tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
    node (v1) at (0,0) [vertex] {};
    node (v2) at (1,0) [vertex] {};
    node (v3) at (1.5,-1) [vertex] {};
    node (v4) at (1,-2) [vertex] {};
    node (v5) at (0,-2) [vertex] {};
    node (v6) at (-.5,-1) [vertex] {};
    node (v7) at (.5,-1) [vertex, fill=blue] {};

    foreach x[evaluate=x as y using int(x-1)] in {2, 3, 4, 5, 6, 7}{
    %pgfmathtruncatemacroy{x - 1}
    draw (vy) to (vx);
    }
    draw (v6) to (v1);
    draw (v5) to (v7);
    draw (v4) to (v7);
    draw (v3) to (v7);
    end{tikzpicture}
    end{document}


    screenshot






    share|improve this answer


























    • On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

      – Abraham
      3 hours ago











    • ok, fixed now !

      – AndréC
      3 hours ago











    • This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

      – Abraham
      3 hours ago













    • I have given two possibilities to correct this problem.

      – AndréC
      3 hours ago



















    1














    To get it more wheel like you can use polar coordinates, like (1,45) to draw a node at distance 1 and 45 degrees from origin. Here is an alternative version with a variable number of nodes. Change the number in numNodes{6} to change the number of nodes n the circle.



    documentclass[border=5mm]{standalone}
    usepackage{tikz}
    begin{document}
    begin{tikzpicture}[
    auto,
    scale=0.9,
    vert/.style={draw, circle, inner sep=0.55mm,fill=white}
    ]
    newcommandnumNodes{6}
    node[vert,fill=blue] (vC) at (0,0){};
    draw (0:1) node[vert](v0) {}
    foreach n [evaluate = n as deg using {n*360/numNodes}] in {1,2,...,numNodes}{
    -- (deg:1) node[vert](vn) {}
    };
    foreach n in {0,3,4,5}{
    draw (vC) -- (vn);
    }
    end{tikzpicture}

    end {document}


    enter image description here






    share|improve this answer
























    • you have a typo (1,45) is not a polar coordinate

      – AndréC
      2 hours ago





















    0














    maybe you will like:



    documentclass[tikz,border=5mm]{standalone}
    usetikzlibrary{shapes.geometric}

    begin{document}
    begin{tikzpicture}[
    vertex/.style = {circle, draw, fill=#1, inner sep=0.5mm}
    ]
    %
    node (s) [regular polygon,regular polygon sides=6,
    draw, minimum size=20mm, above] at (0.5,-2) {};
    draw (s.corner 3) -- (s.corner 6);
    node (c) [vertex=blue] at (s.center) {};
    %
    foreach i in {1,...,6}{node (si) [vertex=white] at (s.corner i) {}; }

    draw (c) -- (s4)
    (c) -- (s5);
    end{tikzpicture}
    end{document}


    enter image description here






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });






      Abraham is a new contributor. Be nice, and check out our Code of Conduct.










      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476800%2ftikz-graph-edges-not-drawn-nicely%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      tikzstyle is deprecated and the issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.



      documentclass[tikz,border=3.14mm]{standalone}
      begin{document}
      begin{tikzpicture}[auto, scale=0.9]
      tikzset{vertex/.style={draw, circle, inner sep=0.55mm}}
      node (v1) at (0,0) [vertex] {};
      node (v2) at (1,0) [vertex] {};
      node (v3) at (1.5,-1) [vertex] {};
      node (v4) at (1,-2) [vertex] {};
      node (v5) at (0,-2) [vertex] {};
      node (v6) at (-.5,-1) [vertex] {};
      node (v7) at (.5,-1) [vertex, fill=blue] {};

      foreach x [remember =x as lastx (initially 1)] in {2, 3, 4, 5, 6, 7}{
      draw (vlastx) to (vx);
      }
      draw (v6) to (v1);
      draw (v5) to (v7);
      draw (v4) to (v7);
      draw (v3) to (v7);
      end{tikzpicture}
      end{document}


      enter image description here






      share|improve this answer




























        2














        tikzstyle is deprecated and the issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.



        documentclass[tikz,border=3.14mm]{standalone}
        begin{document}
        begin{tikzpicture}[auto, scale=0.9]
        tikzset{vertex/.style={draw, circle, inner sep=0.55mm}}
        node (v1) at (0,0) [vertex] {};
        node (v2) at (1,0) [vertex] {};
        node (v3) at (1.5,-1) [vertex] {};
        node (v4) at (1,-2) [vertex] {};
        node (v5) at (0,-2) [vertex] {};
        node (v6) at (-.5,-1) [vertex] {};
        node (v7) at (.5,-1) [vertex, fill=blue] {};

        foreach x [remember =x as lastx (initially 1)] in {2, 3, 4, 5, 6, 7}{
        draw (vlastx) to (vx);
        }
        draw (v6) to (v1);
        draw (v5) to (v7);
        draw (v4) to (v7);
        draw (v3) to (v7);
        end{tikzpicture}
        end{document}


        enter image description here






        share|improve this answer


























          2












          2








          2







          tikzstyle is deprecated and the issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.



          documentclass[tikz,border=3.14mm]{standalone}
          begin{document}
          begin{tikzpicture}[auto, scale=0.9]
          tikzset{vertex/.style={draw, circle, inner sep=0.55mm}}
          node (v1) at (0,0) [vertex] {};
          node (v2) at (1,0) [vertex] {};
          node (v3) at (1.5,-1) [vertex] {};
          node (v4) at (1,-2) [vertex] {};
          node (v5) at (0,-2) [vertex] {};
          node (v6) at (-.5,-1) [vertex] {};
          node (v7) at (.5,-1) [vertex, fill=blue] {};

          foreach x [remember =x as lastx (initially 1)] in {2, 3, 4, 5, 6, 7}{
          draw (vlastx) to (vx);
          }
          draw (v6) to (v1);
          draw (v5) to (v7);
          draw (v4) to (v7);
          draw (v3) to (v7);
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer













          tikzstyle is deprecated and the issue is that pgfmathsetmacro does not yield integers, but something like 2.0, where .0 gets interpreted as node anchor.



          documentclass[tikz,border=3.14mm]{standalone}
          begin{document}
          begin{tikzpicture}[auto, scale=0.9]
          tikzset{vertex/.style={draw, circle, inner sep=0.55mm}}
          node (v1) at (0,0) [vertex] {};
          node (v2) at (1,0) [vertex] {};
          node (v3) at (1.5,-1) [vertex] {};
          node (v4) at (1,-2) [vertex] {};
          node (v5) at (0,-2) [vertex] {};
          node (v6) at (-.5,-1) [vertex] {};
          node (v7) at (.5,-1) [vertex, fill=blue] {};

          foreach x [remember =x as lastx (initially 1)] in {2, 3, 4, 5, 6, 7}{
          draw (vlastx) to (vx);
          }
          draw (v6) to (v1);
          draw (v5) to (v7);
          draw (v4) to (v7);
          draw (v3) to (v7);
          end{tikzpicture}
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 3 hours ago









          marmotmarmot

          104k4123234




          104k4123234























              2














              That's because the calculation of y doesn't give an integer. There are two possibilities:




              • the first is to use the macro pgfmathtruncatemacro instead of pgfmathsetmacro

              • the second is to evaluate y within the foreach loop itself




              documentclass[tikz,border=5mm]{standalone}

              usetikzlibrary{calc}

              begin{document}
              begin{tikzpicture}[auto, scale=0.9]
              tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
              node (v1) at (0,0) [vertex] {};
              node (v2) at (1,0) [vertex] {};
              node (v3) at (1.5,-1) [vertex] {};
              node (v4) at (1,-2) [vertex] {};
              node (v5) at (0,-2) [vertex] {};
              node (v6) at (-.5,-1) [vertex] {};
              node (v7) at (.5,-1) [vertex, fill=blue] {};

              foreach x[evaluate=x as y using int(x-1)] in {2, 3, 4, 5, 6, 7}{
              %pgfmathtruncatemacroy{x - 1}
              draw (vy) to (vx);
              }
              draw (v6) to (v1);
              draw (v5) to (v7);
              draw (v4) to (v7);
              draw (v3) to (v7);
              end{tikzpicture}
              end{document}


              screenshot






              share|improve this answer


























              • On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

                – Abraham
                3 hours ago











              • ok, fixed now !

                – AndréC
                3 hours ago











              • This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

                – Abraham
                3 hours ago













              • I have given two possibilities to correct this problem.

                – AndréC
                3 hours ago
















              2














              That's because the calculation of y doesn't give an integer. There are two possibilities:




              • the first is to use the macro pgfmathtruncatemacro instead of pgfmathsetmacro

              • the second is to evaluate y within the foreach loop itself




              documentclass[tikz,border=5mm]{standalone}

              usetikzlibrary{calc}

              begin{document}
              begin{tikzpicture}[auto, scale=0.9]
              tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
              node (v1) at (0,0) [vertex] {};
              node (v2) at (1,0) [vertex] {};
              node (v3) at (1.5,-1) [vertex] {};
              node (v4) at (1,-2) [vertex] {};
              node (v5) at (0,-2) [vertex] {};
              node (v6) at (-.5,-1) [vertex] {};
              node (v7) at (.5,-1) [vertex, fill=blue] {};

              foreach x[evaluate=x as y using int(x-1)] in {2, 3, 4, 5, 6, 7}{
              %pgfmathtruncatemacroy{x - 1}
              draw (vy) to (vx);
              }
              draw (v6) to (v1);
              draw (v5) to (v7);
              draw (v4) to (v7);
              draw (v3) to (v7);
              end{tikzpicture}
              end{document}


              screenshot






              share|improve this answer


























              • On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

                – Abraham
                3 hours ago











              • ok, fixed now !

                – AndréC
                3 hours ago











              • This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

                – Abraham
                3 hours ago













              • I have given two possibilities to correct this problem.

                – AndréC
                3 hours ago














              2












              2








              2







              That's because the calculation of y doesn't give an integer. There are two possibilities:




              • the first is to use the macro pgfmathtruncatemacro instead of pgfmathsetmacro

              • the second is to evaluate y within the foreach loop itself




              documentclass[tikz,border=5mm]{standalone}

              usetikzlibrary{calc}

              begin{document}
              begin{tikzpicture}[auto, scale=0.9]
              tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
              node (v1) at (0,0) [vertex] {};
              node (v2) at (1,0) [vertex] {};
              node (v3) at (1.5,-1) [vertex] {};
              node (v4) at (1,-2) [vertex] {};
              node (v5) at (0,-2) [vertex] {};
              node (v6) at (-.5,-1) [vertex] {};
              node (v7) at (.5,-1) [vertex, fill=blue] {};

              foreach x[evaluate=x as y using int(x-1)] in {2, 3, 4, 5, 6, 7}{
              %pgfmathtruncatemacroy{x - 1}
              draw (vy) to (vx);
              }
              draw (v6) to (v1);
              draw (v5) to (v7);
              draw (v4) to (v7);
              draw (v3) to (v7);
              end{tikzpicture}
              end{document}


              screenshot






              share|improve this answer















              That's because the calculation of y doesn't give an integer. There are two possibilities:




              • the first is to use the macro pgfmathtruncatemacro instead of pgfmathsetmacro

              • the second is to evaluate y within the foreach loop itself




              documentclass[tikz,border=5mm]{standalone}

              usetikzlibrary{calc}

              begin{document}
              begin{tikzpicture}[auto, scale=0.9]
              tikzstyle{vertex}=[draw, circle, inner sep=0.55mm]
              node (v1) at (0,0) [vertex] {};
              node (v2) at (1,0) [vertex] {};
              node (v3) at (1.5,-1) [vertex] {};
              node (v4) at (1,-2) [vertex] {};
              node (v5) at (0,-2) [vertex] {};
              node (v6) at (-.5,-1) [vertex] {};
              node (v7) at (.5,-1) [vertex, fill=blue] {};

              foreach x[evaluate=x as y using int(x-1)] in {2, 3, 4, 5, 6, 7}{
              %pgfmathtruncatemacroy{x - 1}
              draw (vy) to (vx);
              }
              draw (v6) to (v1);
              draw (v5) to (v7);
              draw (v4) to (v7);
              draw (v3) to (v7);
              end{tikzpicture}
              end{document}


              screenshot







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 3 hours ago

























              answered 3 hours ago









              AndréCAndréC

              9,31111447




              9,31111447













              • On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

                – Abraham
                3 hours ago











              • ok, fixed now !

                – AndréC
                3 hours ago











              • This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

                – Abraham
                3 hours ago













              • I have given two possibilities to correct this problem.

                – AndréC
                3 hours ago



















              • On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

                – Abraham
                3 hours ago











              • ok, fixed now !

                – AndréC
                3 hours ago











              • This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

                – Abraham
                3 hours ago













              • I have given two possibilities to correct this problem.

                – AndréC
                3 hours ago

















              On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

              – Abraham
              3 hours ago





              On my computer the line foreach x[evaluate=x as y using int(x-1)]☺ in {2, 3, 4, 5, 6, 7}{ looks like it has an smiley face in it...

              – Abraham
              3 hours ago













              ok, fixed now !

              – AndréC
              3 hours ago





              ok, fixed now !

              – AndréC
              3 hours ago













              This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

              – Abraham
              3 hours ago







              This works, seems that pgfmathsetmacro was the problem, as @marmot explained. Thank you!

              – Abraham
              3 hours ago















              I have given two possibilities to correct this problem.

              – AndréC
              3 hours ago





              I have given two possibilities to correct this problem.

              – AndréC
              3 hours ago











              1














              To get it more wheel like you can use polar coordinates, like (1,45) to draw a node at distance 1 and 45 degrees from origin. Here is an alternative version with a variable number of nodes. Change the number in numNodes{6} to change the number of nodes n the circle.



              documentclass[border=5mm]{standalone}
              usepackage{tikz}
              begin{document}
              begin{tikzpicture}[
              auto,
              scale=0.9,
              vert/.style={draw, circle, inner sep=0.55mm,fill=white}
              ]
              newcommandnumNodes{6}
              node[vert,fill=blue] (vC) at (0,0){};
              draw (0:1) node[vert](v0) {}
              foreach n [evaluate = n as deg using {n*360/numNodes}] in {1,2,...,numNodes}{
              -- (deg:1) node[vert](vn) {}
              };
              foreach n in {0,3,4,5}{
              draw (vC) -- (vn);
              }
              end{tikzpicture}

              end {document}


              enter image description here






              share|improve this answer
























              • you have a typo (1,45) is not a polar coordinate

                – AndréC
                2 hours ago


















              1














              To get it more wheel like you can use polar coordinates, like (1,45) to draw a node at distance 1 and 45 degrees from origin. Here is an alternative version with a variable number of nodes. Change the number in numNodes{6} to change the number of nodes n the circle.



              documentclass[border=5mm]{standalone}
              usepackage{tikz}
              begin{document}
              begin{tikzpicture}[
              auto,
              scale=0.9,
              vert/.style={draw, circle, inner sep=0.55mm,fill=white}
              ]
              newcommandnumNodes{6}
              node[vert,fill=blue] (vC) at (0,0){};
              draw (0:1) node[vert](v0) {}
              foreach n [evaluate = n as deg using {n*360/numNodes}] in {1,2,...,numNodes}{
              -- (deg:1) node[vert](vn) {}
              };
              foreach n in {0,3,4,5}{
              draw (vC) -- (vn);
              }
              end{tikzpicture}

              end {document}


              enter image description here






              share|improve this answer
























              • you have a typo (1,45) is not a polar coordinate

                – AndréC
                2 hours ago
















              1












              1








              1







              To get it more wheel like you can use polar coordinates, like (1,45) to draw a node at distance 1 and 45 degrees from origin. Here is an alternative version with a variable number of nodes. Change the number in numNodes{6} to change the number of nodes n the circle.



              documentclass[border=5mm]{standalone}
              usepackage{tikz}
              begin{document}
              begin{tikzpicture}[
              auto,
              scale=0.9,
              vert/.style={draw, circle, inner sep=0.55mm,fill=white}
              ]
              newcommandnumNodes{6}
              node[vert,fill=blue] (vC) at (0,0){};
              draw (0:1) node[vert](v0) {}
              foreach n [evaluate = n as deg using {n*360/numNodes}] in {1,2,...,numNodes}{
              -- (deg:1) node[vert](vn) {}
              };
              foreach n in {0,3,4,5}{
              draw (vC) -- (vn);
              }
              end{tikzpicture}

              end {document}


              enter image description here






              share|improve this answer













              To get it more wheel like you can use polar coordinates, like (1,45) to draw a node at distance 1 and 45 degrees from origin. Here is an alternative version with a variable number of nodes. Change the number in numNodes{6} to change the number of nodes n the circle.



              documentclass[border=5mm]{standalone}
              usepackage{tikz}
              begin{document}
              begin{tikzpicture}[
              auto,
              scale=0.9,
              vert/.style={draw, circle, inner sep=0.55mm,fill=white}
              ]
              newcommandnumNodes{6}
              node[vert,fill=blue] (vC) at (0,0){};
              draw (0:1) node[vert](v0) {}
              foreach n [evaluate = n as deg using {n*360/numNodes}] in {1,2,...,numNodes}{
              -- (deg:1) node[vert](vn) {}
              };
              foreach n in {0,3,4,5}{
              draw (vC) -- (vn);
              }
              end{tikzpicture}

              end {document}


              enter image description here







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 2 hours ago









              StefanHStefanH

              10.6k1820




              10.6k1820













              • you have a typo (1,45) is not a polar coordinate

                – AndréC
                2 hours ago





















              • you have a typo (1,45) is not a polar coordinate

                – AndréC
                2 hours ago



















              you have a typo (1,45) is not a polar coordinate

              – AndréC
              2 hours ago







              you have a typo (1,45) is not a polar coordinate

              – AndréC
              2 hours ago













              0














              maybe you will like:



              documentclass[tikz,border=5mm]{standalone}
              usetikzlibrary{shapes.geometric}

              begin{document}
              begin{tikzpicture}[
              vertex/.style = {circle, draw, fill=#1, inner sep=0.5mm}
              ]
              %
              node (s) [regular polygon,regular polygon sides=6,
              draw, minimum size=20mm, above] at (0.5,-2) {};
              draw (s.corner 3) -- (s.corner 6);
              node (c) [vertex=blue] at (s.center) {};
              %
              foreach i in {1,...,6}{node (si) [vertex=white] at (s.corner i) {}; }

              draw (c) -- (s4)
              (c) -- (s5);
              end{tikzpicture}
              end{document}


              enter image description here






              share|improve this answer




























                0














                maybe you will like:



                documentclass[tikz,border=5mm]{standalone}
                usetikzlibrary{shapes.geometric}

                begin{document}
                begin{tikzpicture}[
                vertex/.style = {circle, draw, fill=#1, inner sep=0.5mm}
                ]
                %
                node (s) [regular polygon,regular polygon sides=6,
                draw, minimum size=20mm, above] at (0.5,-2) {};
                draw (s.corner 3) -- (s.corner 6);
                node (c) [vertex=blue] at (s.center) {};
                %
                foreach i in {1,...,6}{node (si) [vertex=white] at (s.corner i) {}; }

                draw (c) -- (s4)
                (c) -- (s5);
                end{tikzpicture}
                end{document}


                enter image description here






                share|improve this answer


























                  0












                  0








                  0







                  maybe you will like:



                  documentclass[tikz,border=5mm]{standalone}
                  usetikzlibrary{shapes.geometric}

                  begin{document}
                  begin{tikzpicture}[
                  vertex/.style = {circle, draw, fill=#1, inner sep=0.5mm}
                  ]
                  %
                  node (s) [regular polygon,regular polygon sides=6,
                  draw, minimum size=20mm, above] at (0.5,-2) {};
                  draw (s.corner 3) -- (s.corner 6);
                  node (c) [vertex=blue] at (s.center) {};
                  %
                  foreach i in {1,...,6}{node (si) [vertex=white] at (s.corner i) {}; }

                  draw (c) -- (s4)
                  (c) -- (s5);
                  end{tikzpicture}
                  end{document}


                  enter image description here






                  share|improve this answer













                  maybe you will like:



                  documentclass[tikz,border=5mm]{standalone}
                  usetikzlibrary{shapes.geometric}

                  begin{document}
                  begin{tikzpicture}[
                  vertex/.style = {circle, draw, fill=#1, inner sep=0.5mm}
                  ]
                  %
                  node (s) [regular polygon,regular polygon sides=6,
                  draw, minimum size=20mm, above] at (0.5,-2) {};
                  draw (s.corner 3) -- (s.corner 6);
                  node (c) [vertex=blue] at (s.center) {};
                  %
                  foreach i in {1,...,6}{node (si) [vertex=white] at (s.corner i) {}; }

                  draw (c) -- (s4)
                  (c) -- (s5);
                  end{tikzpicture}
                  end{document}


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 hours ago









                  ZarkoZarko

                  125k867164




                  125k867164






















                      Abraham is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      Abraham is a new contributor. Be nice, and check out our Code of Conduct.













                      Abraham is a new contributor. Be nice, and check out our Code of Conduct.












                      Abraham is a new contributor. Be nice, and check out our Code of Conduct.
















                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476800%2ftikz-graph-edges-not-drawn-nicely%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      List of shipwrecks in 1808...

                      Is there a lightweight tool to crop images quickly?Cropping Images using Command Line Tools OnlyHow to crop...

                      Unit packagekit.service is masked Announcing the arrival of Valued Associate #679: Cesar...