Not setting the location when using tikz












2















I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?



For now I used:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


Output:



enter image description here



But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


And the output should be the same (maybe 90 degree different but same logic).



The main goal is to just declare the path and tikz will do the hard work for me.



I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.



Is it possible to somehow create graph without declaring the coordinates for each node?










share|improve this question

























  • Yes, it seems to me you are looking for the chains library.

    – marmot
    Jan 20 at 22:53
















2















I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?



For now I used:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


Output:



enter image description here



But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


And the output should be the same (maybe 90 degree different but same logic).



The main goal is to just declare the path and tikz will do the hard work for me.



I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.



Is it possible to somehow create graph without declaring the coordinates for each node?










share|improve this question

























  • Yes, it seems to me you are looking for the chains library.

    – marmot
    Jan 20 at 22:53














2












2








2








I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?



For now I used:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


Output:



enter image description here



But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


And the output should be the same (maybe 90 degree different but same logic).



The main goal is to just declare the path and tikz will do the hard work for me.



I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.



Is it possible to somehow create graph without declaring the coordinates for each node?










share|improve this question
















I'm using tikz in LyX. I'm trying to build a basic graph. Is it possible to somehow add the path of the nodes without setting the location of each one?



For now I used:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) at (0,0) {$v_1$};
node[circle,draw] (B) at (4,0) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


Output:



enter image description here



But is it possible to remove the at (4,0) part so tikz will generator the graph alone? I don't really care where the nodes are located, I just care about the exitness of them and the paths between them. The desired code looks something like:



begin{tikzpicture}
[scale=.8,auto=left,node/.style={circle,draw}]
node[circle,draw] (A) {$v_1$};
node[circle,draw] (B) {$v_2$};
draw[->] (A)--(B) node[midway,above]{$e_0$};
end{tikzpicture}


And the output should be the same (maybe 90 degree different but same logic).



The main goal is to just declare the path and tikz will do the hard work for me.



I was using the WebGraphviz (Graphviz in the Browser). There I could just declare the paths it would build the graph for me (without setting the locations). I understood that it is not possible to use Graphviz in LyX and everyone who uses it, uploads an image instead. I prefer to build the nodes so it would look better.



Is it possible to somehow create graph without declaring the coordinates for each node?







tikz-pgf lyx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 20 at 22:08







vesii

















asked Jan 20 at 22:02









vesiivesii

785




785













  • Yes, it seems to me you are looking for the chains library.

    – marmot
    Jan 20 at 22:53



















  • Yes, it seems to me you are looking for the chains library.

    – marmot
    Jan 20 at 22:53

















Yes, it seems to me you are looking for the chains library.

– marmot
Jan 20 at 22:53





Yes, it seems to me you are looking for the chains library.

– marmot
Jan 20 at 22:53










2 Answers
2






active

oldest

votes


















2














The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).



graph



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

begin{document}

begin{tikzpicture}
graph[grow right=30mm,nodes={circle,draw}] {
1 ->[edge label={a}] 2 ->[edge label={b}] 3;
1 -- [bend right,edge label'={c}] 3;
};
end{tikzpicture}

end{document}





share|improve this answer































    1














    A very minimal realization of your suggestion might be



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{chains}
    begin{document}
    begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
    node [c,on chain] {A};
    node [c,on chain] {B};
    end{tikzpicture}
    end{document}


    enter image description here



    A slightly more sophisticated version could be



    documentclass[tikz,border=3.14mm]{standalone}
    usetikzlibrary{chains,decorations.markings}
    newcounter{eindex}
    begin{document}
    begin{tikzpicture}[node distance=2.4cm,start chain,%
    midmark/.style={postaction={decorate,decoration={markings,
    mark=at position 0.5 with {stepcounter{eindex}
    node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
    c/.style={circle,draw,join},every join/.style={-latex,midmark}]
    node [c,on chain] {A};
    node [c,on chain] {B};
    node [c,on chain] {C};
    end{tikzpicture}
    end{document}


    enter image description here



    Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.






    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
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471054%2fnot-setting-the-location-when-using-tikz%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).



      graph



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

      begin{document}

      begin{tikzpicture}
      graph[grow right=30mm,nodes={circle,draw}] {
      1 ->[edge label={a}] 2 ->[edge label={b}] 3;
      1 -- [bend right,edge label'={c}] 3;
      };
      end{tikzpicture}

      end{document}





      share|improve this answer




























        2














        The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).



        graph



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

        begin{document}

        begin{tikzpicture}
        graph[grow right=30mm,nodes={circle,draw}] {
        1 ->[edge label={a}] 2 ->[edge label={b}] 3;
        1 -- [bend right,edge label'={c}] 3;
        };
        end{tikzpicture}

        end{document}





        share|improve this answer


























          2












          2








          2







          The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).



          graph



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

          begin{document}

          begin{tikzpicture}
          graph[grow right=30mm,nodes={circle,draw}] {
          1 ->[edge label={a}] 2 ->[edge label={b}] 3;
          1 -- [bend right,edge label'={c}] 3;
          };
          end{tikzpicture}

          end{document}





          share|improve this answer













          The graphs library allows you not to worry about the location of nodes (see page 408 et seq. of manual 3.1).



          graph



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

          begin{document}

          begin{tikzpicture}
          graph[grow right=30mm,nodes={circle,draw}] {
          1 ->[edge label={a}] 2 ->[edge label={b}] 3;
          1 -- [bend right,edge label'={c}] 3;
          };
          end{tikzpicture}

          end{document}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 21 at 6:26









          AndréCAndréC

          8,78411447




          8,78411447























              1














              A very minimal realization of your suggestion might be



              documentclass[tikz,border=3.14mm]{standalone}
              usetikzlibrary{chains}
              begin{document}
              begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
              node [c,on chain] {A};
              node [c,on chain] {B};
              end{tikzpicture}
              end{document}


              enter image description here



              A slightly more sophisticated version could be



              documentclass[tikz,border=3.14mm]{standalone}
              usetikzlibrary{chains,decorations.markings}
              newcounter{eindex}
              begin{document}
              begin{tikzpicture}[node distance=2.4cm,start chain,%
              midmark/.style={postaction={decorate,decoration={markings,
              mark=at position 0.5 with {stepcounter{eindex}
              node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
              c/.style={circle,draw,join},every join/.style={-latex,midmark}]
              node [c,on chain] {A};
              node [c,on chain] {B};
              node [c,on chain] {C};
              end{tikzpicture}
              end{document}


              enter image description here



              Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.






              share|improve this answer






























                1














                A very minimal realization of your suggestion might be



                documentclass[tikz,border=3.14mm]{standalone}
                usetikzlibrary{chains}
                begin{document}
                begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
                node [c,on chain] {A};
                node [c,on chain] {B};
                end{tikzpicture}
                end{document}


                enter image description here



                A slightly more sophisticated version could be



                documentclass[tikz,border=3.14mm]{standalone}
                usetikzlibrary{chains,decorations.markings}
                newcounter{eindex}
                begin{document}
                begin{tikzpicture}[node distance=2.4cm,start chain,%
                midmark/.style={postaction={decorate,decoration={markings,
                mark=at position 0.5 with {stepcounter{eindex}
                node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
                c/.style={circle,draw,join},every join/.style={-latex,midmark}]
                node [c,on chain] {A};
                node [c,on chain] {B};
                node [c,on chain] {C};
                end{tikzpicture}
                end{document}


                enter image description here



                Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.






                share|improve this answer




























                  1












                  1








                  1







                  A very minimal realization of your suggestion might be



                  documentclass[tikz,border=3.14mm]{standalone}
                  usetikzlibrary{chains}
                  begin{document}
                  begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
                  node [c,on chain] {A};
                  node [c,on chain] {B};
                  end{tikzpicture}
                  end{document}


                  enter image description here



                  A slightly more sophisticated version could be



                  documentclass[tikz,border=3.14mm]{standalone}
                  usetikzlibrary{chains,decorations.markings}
                  newcounter{eindex}
                  begin{document}
                  begin{tikzpicture}[node distance=2.4cm,start chain,%
                  midmark/.style={postaction={decorate,decoration={markings,
                  mark=at position 0.5 with {stepcounter{eindex}
                  node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
                  c/.style={circle,draw,join},every join/.style={-latex,midmark}]
                  node [c,on chain] {A};
                  node [c,on chain] {B};
                  node [c,on chain] {C};
                  end{tikzpicture}
                  end{document}


                  enter image description here



                  Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.






                  share|improve this answer















                  A very minimal realization of your suggestion might be



                  documentclass[tikz,border=3.14mm]{standalone}
                  usetikzlibrary{chains}
                  begin{document}
                  begin{tikzpicture}[start chain,c/.style={circle,draw,join},every join/.style={-latex}]
                  node [c,on chain] {A};
                  node [c,on chain] {B};
                  end{tikzpicture}
                  end{document}


                  enter image description here



                  A slightly more sophisticated version could be



                  documentclass[tikz,border=3.14mm]{standalone}
                  usetikzlibrary{chains,decorations.markings}
                  newcounter{eindex}
                  begin{document}
                  begin{tikzpicture}[node distance=2.4cm,start chain,%
                  midmark/.style={postaction={decorate,decoration={markings,
                  mark=at position 0.5 with {stepcounter{eindex}
                  node[anchor=south] at (0,0.1){$e_{theeindex}$};}}}},
                  c/.style={circle,draw,join},every join/.style={-latex,midmark}]
                  node [c,on chain] {A};
                  node [c,on chain] {B};
                  node [c,on chain] {C};
                  end{tikzpicture}
                  end{document}


                  enter image description here



                  Of course the chains can go in any direction and there are many more things, as you can see in section 48 of the pgfmanual.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 20 at 23:05

























                  answered Jan 20 at 22:59









                  marmotmarmot

                  95.1k4110210




                  95.1k4110210






























                      draft saved

                      draft discarded




















































                      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%2f471054%2fnot-setting-the-location-when-using-tikz%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

                      How to send String Array data to Server using php in android

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                      Is anime1.com a legal site for watching anime?