Dyck paths behaving as nodes

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite
1












I am sort of having two main issues with Dyck paths. I'm trying to get to the image on the left (which I edited it with Paint), and what I currently have is the image on the right. I believe that what I need to do, is have these Dyck paths behave as nodes in order to be able to connect them with an edge, but what I have tried thus far has not led me to this. I am clueless as to how may I have the numbers on the bottom printed as well. I've thought about these numbers as nodes also, but I personally believe that maybe it will be complicating things a bit too much.



I hope I have made myself clear.



Thank you for any help I can get.



enter image description here



This is the code I currently have:



documentclassarticle
usepackagetikz
usepackagepdflscape
newcommanddyckpath[3]
fill[white] (#1) rectangle +(#2,#2);
fill[fill=white]
(#1)
foreach dir in #3
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
thispagestyleempty
beginlandscape
centering
begintikzpicture[scale=0.7]
dyckpath0,031,1,1,0,0,0;
dyckpath0,-521,1,0,0;
endtikzpicture
endlandscape
enddocument






share|improve this question


























    up vote
    7
    down vote

    favorite
    1












    I am sort of having two main issues with Dyck paths. I'm trying to get to the image on the left (which I edited it with Paint), and what I currently have is the image on the right. I believe that what I need to do, is have these Dyck paths behave as nodes in order to be able to connect them with an edge, but what I have tried thus far has not led me to this. I am clueless as to how may I have the numbers on the bottom printed as well. I've thought about these numbers as nodes also, but I personally believe that maybe it will be complicating things a bit too much.



    I hope I have made myself clear.



    Thank you for any help I can get.



    enter image description here



    This is the code I currently have:



    documentclassarticle
    usepackagetikz
    usepackagepdflscape
    newcommanddyckpath[3]
    fill[white] (#1) rectangle +(#2,#2);
    fill[fill=white]
    (#1)
    foreach dir in #3
    ifnumdir=0
    -- ++(1,0)
    else
    -- ++(0,1)
    fi


    begindocument
    thispagestyleempty
    beginlandscape
    centering
    begintikzpicture[scale=0.7]
    dyckpath0,031,1,1,0,0,0;
    dyckpath0,-521,1,0,0;
    endtikzpicture
    endlandscape
    enddocument






    share|improve this question
























      up vote
      7
      down vote

      favorite
      1









      up vote
      7
      down vote

      favorite
      1






      1





      I am sort of having two main issues with Dyck paths. I'm trying to get to the image on the left (which I edited it with Paint), and what I currently have is the image on the right. I believe that what I need to do, is have these Dyck paths behave as nodes in order to be able to connect them with an edge, but what I have tried thus far has not led me to this. I am clueless as to how may I have the numbers on the bottom printed as well. I've thought about these numbers as nodes also, but I personally believe that maybe it will be complicating things a bit too much.



      I hope I have made myself clear.



      Thank you for any help I can get.



      enter image description here



      This is the code I currently have:



      documentclassarticle
      usepackagetikz
      usepackagepdflscape
      newcommanddyckpath[3]
      fill[white] (#1) rectangle +(#2,#2);
      fill[fill=white]
      (#1)
      foreach dir in #3
      ifnumdir=0
      -- ++(1,0)
      else
      -- ++(0,1)
      fi


      begindocument
      thispagestyleempty
      beginlandscape
      centering
      begintikzpicture[scale=0.7]
      dyckpath0,031,1,1,0,0,0;
      dyckpath0,-521,1,0,0;
      endtikzpicture
      endlandscape
      enddocument






      share|improve this question














      I am sort of having two main issues with Dyck paths. I'm trying to get to the image on the left (which I edited it with Paint), and what I currently have is the image on the right. I believe that what I need to do, is have these Dyck paths behave as nodes in order to be able to connect them with an edge, but what I have tried thus far has not led me to this. I am clueless as to how may I have the numbers on the bottom printed as well. I've thought about these numbers as nodes also, but I personally believe that maybe it will be complicating things a bit too much.



      I hope I have made myself clear.



      Thank you for any help I can get.



      enter image description here



      This is the code I currently have:



      documentclassarticle
      usepackagetikz
      usepackagepdflscape
      newcommanddyckpath[3]
      fill[white] (#1) rectangle +(#2,#2);
      fill[fill=white]
      (#1)
      foreach dir in #3
      ifnumdir=0
      -- ++(1,0)
      else
      -- ++(0,1)
      fi


      begindocument
      thispagestyleempty
      beginlandscape
      centering
      begintikzpicture[scale=0.7]
      dyckpath0,031,1,1,0,0,0;
      dyckpath0,-521,1,0,0;
      endtikzpicture
      endlandscape
      enddocument








      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 17 at 11:39









      Bernard

      155k763189




      155k763189










      asked Aug 17 at 11:36









      Stiven G

      623




      623




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          I found for this application the inline version of foreach to be slightly more convenient. I added a fourth argument which should hold the name of the Dyck path, so you can draw edges between them. (I made the color of the second fill command something different than white to see what it does, it does seem to do something :). )



          Edit

          I added a fifth argument which determines the number of numbers to print, if this is larger than the size, it will also draw the little black dots.



          enter image description here



          documentclassarticle

          usepackagetikz
          usepackagepdflscape

          newcommanddyckpath[5]- (#1);
          path[fill] (#1) foreach i [count=j] in 0,...,#5 +(i,0) node[anchor=north]j ifnumi>#2 circle (1pt) fi;
          draw[help lines] (#1) grid +(#2,#2);
          draw[line width=2pt] (#1) foreach dir in #3 -- ++(dir*90:1);
          endscope


          begindocument
          thispagestyleempty
          beginlandscape
          centering
          begintikzpicture[scale=0.7]
          dyckpath0,031,1,1,0,0,0dyck13;
          dyckpath0,-521,1,0,0dyck23;
          dyckpath5,031,0,1,0,1,0dyck33;

          draw (dyck1) -- (dyck2);
          draw (dyck2) -- (dyck3);
          endtikzpicture
          endlandscape
          enddocument


          PS I don't know if its useful, because I don't know what a Dyck path is, but using 2 or 3 in the directions list will allow you to to move left and down too. So



          dyckpath0,051,1,1,1,1,0,0,0,0,0,3,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,3,3,3,2,2,1,1,0,35


          leads to



          enter image description here



          Edit 2

          As per request I adjusted the way the numbers are drawn. The last (5th) argument now must be a comma-separated list of numbers.



          enter image description here



          documentclassarticle

          usepackagetikz
          usepackagepdflscape

          newcommanddyckpath[5]
          beginscope[local bounding box=#4]
          fill[white] (#1) rectangle +(#2,#2);
          fill[red!25!white] (#1) foreach dir in #3-- ++(dir*90:1)

          begindocument
          thispagestyleempty
          beginlandscape
          centering
          begintikzpicture[scale=0.7]
          dyckpath0,031,1,1,0,0,0dyck11,2,3,4;
          dyckpath0,-521,1,0,0dyck21,2,3,4;
          dyckpath5,031,0,1,0,1,0dyck31,4,3,2;
          dyckpath5,-531,0,1,0,1,0dyck41,4,2;

          foreach i in 2,3,4
          draw (dyck1) -- (dycki);

          endtikzpicture
          endlandscape
          enddocument





          share|improve this answer






















          • This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
            – Stiven G
            Aug 17 at 14:49






          • 1




            @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
            – Max
            Aug 17 at 14:58

















          up vote
          4
          down vote













          Following code shows how to write numbers below the grid. But it uses grid size to finish the list, I don't know how to know that second grid should print 4.



          The edge between grids is just a line between know coordinates.



          documentclassarticle
          usepackagetikz
          usepackagepdflscape
          newcommanddyckpath[3]
          fill[white] (#1) rectangle +(#2,#2);
          fill[fill=white]
          (#1)
          foreach dir in #3
          ifnumdir=0
          -- ++(1,0)
          else
          -- ++(0,1)
          fi


          begindocument
          thispagestyleempty
          beginlandscape
          centering
          begintikzpicture[scale=0.7]
          dyckpath0,031,1,1,0,0,0;
          dyckpath0,-521,1,0,0;
          draw[shorten >=3mm,shorten <=3mm] (1,-3)--(1.5,0);
          endtikzpicture
          endlandscape
          enddocument


          enter image description here






          share|improve this answer



























            up vote
            3
            down vote













            just for fun an adaptation that uses the excellent codes with some additional details according to taste, an arrow for each direction, option to change the size, use the library fit, to generate a node that contains only the grid, in that way the arrows always come from the center of it and it is possible to place a text in the desired position around it, also add names for certain nodes such as the numbers from which you can connect using their names.



            RESULT:



            enter image description here



            MWE:



            documentclass[border=0pt]standalone
            usepackagetikz
            usetikzlibrarybackgrounds,arrows.meta,fit
            begindocument
            begintikzpicture[
            %Environmet config
            >=Stealth[inset=0pt,length=7pt],
            %Environment Styles
            background rectangle/.style=%Seting the background styles
            fill=brown!50!orange!50,
            ,
            show background rectangle, % Indicates to activate the background.
            ]

            defDyckpath(#1)(#2)[#3][#4](#5)#6%1:Position, 2: DickpathName, 3: X dimension, 4: Y dimension, 5: X labels 6: moves
            beginscope[shift=(#1)]
            draw[black!80,step=1,line width=0.5pt] (0,0) grid (#3,#4);
            coordinate (temp) at (0,0); node(a) at (0,0); node(b) at (#3,#4);
            node[fit=(a)(b),label=[anchor=west]north west:#2,inner ysep=10pt](#2);
            foreach dir in #6
            draw[->,line width=1.5pt] (temp) -- ++(90*dir:1) coordinate (temp);
            foreach value [count=j] in 0,1,...,#5
            ifnumvalue>#3 draw[fill](value,-0.5) node(#2-j) j ++(0,0.5) circle (1pt);
            else draw[fill](value,-0.5) node(#2-j) j; fi

            endscope



            Dyckpath(0,0)(Graph1)[4][4](4)1,1,1,1,0,0,0,0
            Dyckpath(6,0)(Graph2)[4][4](4)1,1,1,0,1,0,0,0
            Dyckpath(12,0)(Graph3)[4][4](4)1,1,0,1,1,0,0,0

            draw[->] (Graph1) -- (Graph2);
            draw[->] (Graph2) -- (Graph3);

            Dyckpath(0,-6)(Graph1-b)[3][3](4)1,1,1,0,0,0
            Dyckpath(0,-10)(Graph1-c)[2][2](4)1,1,0,0

            draw[->] (Graph1-3) -- ++(0,-1) -| (Graph1-b);
            draw[->] (Graph1-b-2) |- ++(1.7,-0.5) |- (Graph1-c.0);
            draw[->,shorten >=15pt] (Graph1-5) -- (Graph1-b-5); %Thanks to max for the observation
            draw[->,shorten >=15pt] (Graph1-b-4) -- (Graph1-c-4);

            Dyckpath(6,-6)(Graph2-b)[4][3](5)1,1,0,1,0,0,0
            Dyckpath(12,-10)(Graph3-b)[3][7](5)1,1,1,1,0,1,1,0,1,0

            draw[->] (Graph3-b) -| (Graph3-5);

            endtikzpicture
            enddocument


            PSD: I work with standalone document class to work with a precompiled tikz drawing, with the imported pdf format output to the main document inside figure environment to obtain better position control even in landscape pages, tables, etc. like in this post Scaling different components of tikzpicture together.






            share|improve this answer






















            • Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
              – Max
              Aug 18 at 11:48










            • Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
              – J Leon V.
              Aug 18 at 13:54










            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f446410%2fdyck-paths-behaving-as-nodes%23new-answer', 'question_page');

            );

            Post as a guest






























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            I found for this application the inline version of foreach to be slightly more convenient. I added a fourth argument which should hold the name of the Dyck path, so you can draw edges between them. (I made the color of the second fill command something different than white to see what it does, it does seem to do something :). )



            Edit

            I added a fifth argument which determines the number of numbers to print, if this is larger than the size, it will also draw the little black dots.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]- (#1);
            path[fill] (#1) foreach i [count=j] in 0,...,#5 +(i,0) node[anchor=north]j ifnumi>#2 circle (1pt) fi;
            draw[help lines] (#1) grid +(#2,#2);
            draw[line width=2pt] (#1) foreach dir in #3 -- ++(dir*90:1);
            endscope


            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck13;
            dyckpath0,-521,1,0,0dyck23;
            dyckpath5,031,0,1,0,1,0dyck33;

            draw (dyck1) -- (dyck2);
            draw (dyck2) -- (dyck3);
            endtikzpicture
            endlandscape
            enddocument


            PS I don't know if its useful, because I don't know what a Dyck path is, but using 2 or 3 in the directions list will allow you to to move left and down too. So



            dyckpath0,051,1,1,1,1,0,0,0,0,0,3,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,3,3,3,2,2,1,1,0,35


            leads to



            enter image description here



            Edit 2

            As per request I adjusted the way the numbers are drawn. The last (5th) argument now must be a comma-separated list of numbers.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]
            beginscope[local bounding box=#4]
            fill[white] (#1) rectangle +(#2,#2);
            fill[red!25!white] (#1) foreach dir in #3-- ++(dir*90:1)

            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck11,2,3,4;
            dyckpath0,-521,1,0,0dyck21,2,3,4;
            dyckpath5,031,0,1,0,1,0dyck31,4,3,2;
            dyckpath5,-531,0,1,0,1,0dyck41,4,2;

            foreach i in 2,3,4
            draw (dyck1) -- (dycki);

            endtikzpicture
            endlandscape
            enddocument





            share|improve this answer






















            • This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
              – Stiven G
              Aug 17 at 14:49






            • 1




              @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
              – Max
              Aug 17 at 14:58














            up vote
            5
            down vote



            accepted










            I found for this application the inline version of foreach to be slightly more convenient. I added a fourth argument which should hold the name of the Dyck path, so you can draw edges between them. (I made the color of the second fill command something different than white to see what it does, it does seem to do something :). )



            Edit

            I added a fifth argument which determines the number of numbers to print, if this is larger than the size, it will also draw the little black dots.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]- (#1);
            path[fill] (#1) foreach i [count=j] in 0,...,#5 +(i,0) node[anchor=north]j ifnumi>#2 circle (1pt) fi;
            draw[help lines] (#1) grid +(#2,#2);
            draw[line width=2pt] (#1) foreach dir in #3 -- ++(dir*90:1);
            endscope


            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck13;
            dyckpath0,-521,1,0,0dyck23;
            dyckpath5,031,0,1,0,1,0dyck33;

            draw (dyck1) -- (dyck2);
            draw (dyck2) -- (dyck3);
            endtikzpicture
            endlandscape
            enddocument


            PS I don't know if its useful, because I don't know what a Dyck path is, but using 2 or 3 in the directions list will allow you to to move left and down too. So



            dyckpath0,051,1,1,1,1,0,0,0,0,0,3,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,3,3,3,2,2,1,1,0,35


            leads to



            enter image description here



            Edit 2

            As per request I adjusted the way the numbers are drawn. The last (5th) argument now must be a comma-separated list of numbers.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]
            beginscope[local bounding box=#4]
            fill[white] (#1) rectangle +(#2,#2);
            fill[red!25!white] (#1) foreach dir in #3-- ++(dir*90:1)

            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck11,2,3,4;
            dyckpath0,-521,1,0,0dyck21,2,3,4;
            dyckpath5,031,0,1,0,1,0dyck31,4,3,2;
            dyckpath5,-531,0,1,0,1,0dyck41,4,2;

            foreach i in 2,3,4
            draw (dyck1) -- (dycki);

            endtikzpicture
            endlandscape
            enddocument





            share|improve this answer






















            • This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
              – Stiven G
              Aug 17 at 14:49






            • 1




              @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
              – Max
              Aug 17 at 14:58












            up vote
            5
            down vote



            accepted







            up vote
            5
            down vote



            accepted






            I found for this application the inline version of foreach to be slightly more convenient. I added a fourth argument which should hold the name of the Dyck path, so you can draw edges between them. (I made the color of the second fill command something different than white to see what it does, it does seem to do something :). )



            Edit

            I added a fifth argument which determines the number of numbers to print, if this is larger than the size, it will also draw the little black dots.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]- (#1);
            path[fill] (#1) foreach i [count=j] in 0,...,#5 +(i,0) node[anchor=north]j ifnumi>#2 circle (1pt) fi;
            draw[help lines] (#1) grid +(#2,#2);
            draw[line width=2pt] (#1) foreach dir in #3 -- ++(dir*90:1);
            endscope


            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck13;
            dyckpath0,-521,1,0,0dyck23;
            dyckpath5,031,0,1,0,1,0dyck33;

            draw (dyck1) -- (dyck2);
            draw (dyck2) -- (dyck3);
            endtikzpicture
            endlandscape
            enddocument


            PS I don't know if its useful, because I don't know what a Dyck path is, but using 2 or 3 in the directions list will allow you to to move left and down too. So



            dyckpath0,051,1,1,1,1,0,0,0,0,0,3,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,3,3,3,2,2,1,1,0,35


            leads to



            enter image description here



            Edit 2

            As per request I adjusted the way the numbers are drawn. The last (5th) argument now must be a comma-separated list of numbers.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]
            beginscope[local bounding box=#4]
            fill[white] (#1) rectangle +(#2,#2);
            fill[red!25!white] (#1) foreach dir in #3-- ++(dir*90:1)

            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck11,2,3,4;
            dyckpath0,-521,1,0,0dyck21,2,3,4;
            dyckpath5,031,0,1,0,1,0dyck31,4,3,2;
            dyckpath5,-531,0,1,0,1,0dyck41,4,2;

            foreach i in 2,3,4
            draw (dyck1) -- (dycki);

            endtikzpicture
            endlandscape
            enddocument





            share|improve this answer














            I found for this application the inline version of foreach to be slightly more convenient. I added a fourth argument which should hold the name of the Dyck path, so you can draw edges between them. (I made the color of the second fill command something different than white to see what it does, it does seem to do something :). )



            Edit

            I added a fifth argument which determines the number of numbers to print, if this is larger than the size, it will also draw the little black dots.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]- (#1);
            path[fill] (#1) foreach i [count=j] in 0,...,#5 +(i,0) node[anchor=north]j ifnumi>#2 circle (1pt) fi;
            draw[help lines] (#1) grid +(#2,#2);
            draw[line width=2pt] (#1) foreach dir in #3 -- ++(dir*90:1);
            endscope


            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck13;
            dyckpath0,-521,1,0,0dyck23;
            dyckpath5,031,0,1,0,1,0dyck33;

            draw (dyck1) -- (dyck2);
            draw (dyck2) -- (dyck3);
            endtikzpicture
            endlandscape
            enddocument


            PS I don't know if its useful, because I don't know what a Dyck path is, but using 2 or 3 in the directions list will allow you to to move left and down too. So



            dyckpath0,051,1,1,1,1,0,0,0,0,0,3,3,3,3,3,2,2,2,2,1,1,1,1,0,0,0,3,3,3,2,2,1,1,0,35


            leads to



            enter image description here



            Edit 2

            As per request I adjusted the way the numbers are drawn. The last (5th) argument now must be a comma-separated list of numbers.



            enter image description here



            documentclassarticle

            usepackagetikz
            usepackagepdflscape

            newcommanddyckpath[5]
            beginscope[local bounding box=#4]
            fill[white] (#1) rectangle +(#2,#2);
            fill[red!25!white] (#1) foreach dir in #3-- ++(dir*90:1)

            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0dyck11,2,3,4;
            dyckpath0,-521,1,0,0dyck21,2,3,4;
            dyckpath5,031,0,1,0,1,0dyck31,4,3,2;
            dyckpath5,-531,0,1,0,1,0dyck41,4,2;

            foreach i in 2,3,4
            draw (dyck1) -- (dycki);

            endtikzpicture
            endlandscape
            enddocument






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 17 at 14:56

























            answered Aug 17 at 12:25









            Max

            5,88811727




            5,88811727











            • This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
              – Stiven G
              Aug 17 at 14:49






            • 1




              @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
              – Max
              Aug 17 at 14:58
















            • This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
              – Stiven G
              Aug 17 at 14:49






            • 1




              @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
              – Max
              Aug 17 at 14:58















            This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
            – Stiven G
            Aug 17 at 14:49




            This has been of much use Max. I just have one question about this. If I wanted to change the order of the numbers for another dyck path, would it be possible?. Lets say intstead of having them as 1234, I would have liked another dyck path with numbers 1342. Would there need to be another argument defined? Thank you.
            – Stiven G
            Aug 17 at 14:49




            1




            1




            @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
            – Max
            Aug 17 at 14:58




            @StivenG Sure, see my edit! This does mean that you have to specify the list of numbers for every graph. Probably there is a nicer way to do this, but unfortunately I cannot spare any more time :(
            – Max
            Aug 17 at 14:58










            up vote
            4
            down vote













            Following code shows how to write numbers below the grid. But it uses grid size to finish the list, I don't know how to know that second grid should print 4.



            The edge between grids is just a line between know coordinates.



            documentclassarticle
            usepackagetikz
            usepackagepdflscape
            newcommanddyckpath[3]
            fill[white] (#1) rectangle +(#2,#2);
            fill[fill=white]
            (#1)
            foreach dir in #3
            ifnumdir=0
            -- ++(1,0)
            else
            -- ++(0,1)
            fi


            begindocument
            thispagestyleempty
            beginlandscape
            centering
            begintikzpicture[scale=0.7]
            dyckpath0,031,1,1,0,0,0;
            dyckpath0,-521,1,0,0;
            draw[shorten >=3mm,shorten <=3mm] (1,-3)--(1.5,0);
            endtikzpicture
            endlandscape
            enddocument


            enter image description here






            share|improve this answer
























              up vote
              4
              down vote













              Following code shows how to write numbers below the grid. But it uses grid size to finish the list, I don't know how to know that second grid should print 4.



              The edge between grids is just a line between know coordinates.



              documentclassarticle
              usepackagetikz
              usepackagepdflscape
              newcommanddyckpath[3]
              fill[white] (#1) rectangle +(#2,#2);
              fill[fill=white]
              (#1)
              foreach dir in #3
              ifnumdir=0
              -- ++(1,0)
              else
              -- ++(0,1)
              fi


              begindocument
              thispagestyleempty
              beginlandscape
              centering
              begintikzpicture[scale=0.7]
              dyckpath0,031,1,1,0,0,0;
              dyckpath0,-521,1,0,0;
              draw[shorten >=3mm,shorten <=3mm] (1,-3)--(1.5,0);
              endtikzpicture
              endlandscape
              enddocument


              enter image description here






              share|improve this answer






















                up vote
                4
                down vote










                up vote
                4
                down vote









                Following code shows how to write numbers below the grid. But it uses grid size to finish the list, I don't know how to know that second grid should print 4.



                The edge between grids is just a line between know coordinates.



                documentclassarticle
                usepackagetikz
                usepackagepdflscape
                newcommanddyckpath[3]
                fill[white] (#1) rectangle +(#2,#2);
                fill[fill=white]
                (#1)
                foreach dir in #3
                ifnumdir=0
                -- ++(1,0)
                else
                -- ++(0,1)
                fi


                begindocument
                thispagestyleempty
                beginlandscape
                centering
                begintikzpicture[scale=0.7]
                dyckpath0,031,1,1,0,0,0;
                dyckpath0,-521,1,0,0;
                draw[shorten >=3mm,shorten <=3mm] (1,-3)--(1.5,0);
                endtikzpicture
                endlandscape
                enddocument


                enter image description here






                share|improve this answer












                Following code shows how to write numbers below the grid. But it uses grid size to finish the list, I don't know how to know that second grid should print 4.



                The edge between grids is just a line between know coordinates.



                documentclassarticle
                usepackagetikz
                usepackagepdflscape
                newcommanddyckpath[3]
                fill[white] (#1) rectangle +(#2,#2);
                fill[fill=white]
                (#1)
                foreach dir in #3
                ifnumdir=0
                -- ++(1,0)
                else
                -- ++(0,1)
                fi


                begindocument
                thispagestyleempty
                beginlandscape
                centering
                begintikzpicture[scale=0.7]
                dyckpath0,031,1,1,0,0,0;
                dyckpath0,-521,1,0,0;
                draw[shorten >=3mm,shorten <=3mm] (1,-3)--(1.5,0);
                endtikzpicture
                endlandscape
                enddocument


                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 17 at 12:24









                Ignasi

                86.7k4153287




                86.7k4153287




















                    up vote
                    3
                    down vote













                    just for fun an adaptation that uses the excellent codes with some additional details according to taste, an arrow for each direction, option to change the size, use the library fit, to generate a node that contains only the grid, in that way the arrows always come from the center of it and it is possible to place a text in the desired position around it, also add names for certain nodes such as the numbers from which you can connect using their names.



                    RESULT:



                    enter image description here



                    MWE:



                    documentclass[border=0pt]standalone
                    usepackagetikz
                    usetikzlibrarybackgrounds,arrows.meta,fit
                    begindocument
                    begintikzpicture[
                    %Environmet config
                    >=Stealth[inset=0pt,length=7pt],
                    %Environment Styles
                    background rectangle/.style=%Seting the background styles
                    fill=brown!50!orange!50,
                    ,
                    show background rectangle, % Indicates to activate the background.
                    ]

                    defDyckpath(#1)(#2)[#3][#4](#5)#6%1:Position, 2: DickpathName, 3: X dimension, 4: Y dimension, 5: X labels 6: moves
                    beginscope[shift=(#1)]
                    draw[black!80,step=1,line width=0.5pt] (0,0) grid (#3,#4);
                    coordinate (temp) at (0,0); node(a) at (0,0); node(b) at (#3,#4);
                    node[fit=(a)(b),label=[anchor=west]north west:#2,inner ysep=10pt](#2);
                    foreach dir in #6
                    draw[->,line width=1.5pt] (temp) -- ++(90*dir:1) coordinate (temp);
                    foreach value [count=j] in 0,1,...,#5
                    ifnumvalue>#3 draw[fill](value,-0.5) node(#2-j) j ++(0,0.5) circle (1pt);
                    else draw[fill](value,-0.5) node(#2-j) j; fi

                    endscope



                    Dyckpath(0,0)(Graph1)[4][4](4)1,1,1,1,0,0,0,0
                    Dyckpath(6,0)(Graph2)[4][4](4)1,1,1,0,1,0,0,0
                    Dyckpath(12,0)(Graph3)[4][4](4)1,1,0,1,1,0,0,0

                    draw[->] (Graph1) -- (Graph2);
                    draw[->] (Graph2) -- (Graph3);

                    Dyckpath(0,-6)(Graph1-b)[3][3](4)1,1,1,0,0,0
                    Dyckpath(0,-10)(Graph1-c)[2][2](4)1,1,0,0

                    draw[->] (Graph1-3) -- ++(0,-1) -| (Graph1-b);
                    draw[->] (Graph1-b-2) |- ++(1.7,-0.5) |- (Graph1-c.0);
                    draw[->,shorten >=15pt] (Graph1-5) -- (Graph1-b-5); %Thanks to max for the observation
                    draw[->,shorten >=15pt] (Graph1-b-4) -- (Graph1-c-4);

                    Dyckpath(6,-6)(Graph2-b)[4][3](5)1,1,0,1,0,0,0
                    Dyckpath(12,-10)(Graph3-b)[3][7](5)1,1,1,1,0,1,1,0,1,0

                    draw[->] (Graph3-b) -| (Graph3-5);

                    endtikzpicture
                    enddocument


                    PSD: I work with standalone document class to work with a precompiled tikz drawing, with the imported pdf format output to the main document inside figure environment to obtain better position control even in landscape pages, tables, etc. like in this post Scaling different components of tikzpicture together.






                    share|improve this answer






















                    • Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
                      – Max
                      Aug 18 at 11:48










                    • Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
                      – J Leon V.
                      Aug 18 at 13:54














                    up vote
                    3
                    down vote













                    just for fun an adaptation that uses the excellent codes with some additional details according to taste, an arrow for each direction, option to change the size, use the library fit, to generate a node that contains only the grid, in that way the arrows always come from the center of it and it is possible to place a text in the desired position around it, also add names for certain nodes such as the numbers from which you can connect using their names.



                    RESULT:



                    enter image description here



                    MWE:



                    documentclass[border=0pt]standalone
                    usepackagetikz
                    usetikzlibrarybackgrounds,arrows.meta,fit
                    begindocument
                    begintikzpicture[
                    %Environmet config
                    >=Stealth[inset=0pt,length=7pt],
                    %Environment Styles
                    background rectangle/.style=%Seting the background styles
                    fill=brown!50!orange!50,
                    ,
                    show background rectangle, % Indicates to activate the background.
                    ]

                    defDyckpath(#1)(#2)[#3][#4](#5)#6%1:Position, 2: DickpathName, 3: X dimension, 4: Y dimension, 5: X labels 6: moves
                    beginscope[shift=(#1)]
                    draw[black!80,step=1,line width=0.5pt] (0,0) grid (#3,#4);
                    coordinate (temp) at (0,0); node(a) at (0,0); node(b) at (#3,#4);
                    node[fit=(a)(b),label=[anchor=west]north west:#2,inner ysep=10pt](#2);
                    foreach dir in #6
                    draw[->,line width=1.5pt] (temp) -- ++(90*dir:1) coordinate (temp);
                    foreach value [count=j] in 0,1,...,#5
                    ifnumvalue>#3 draw[fill](value,-0.5) node(#2-j) j ++(0,0.5) circle (1pt);
                    else draw[fill](value,-0.5) node(#2-j) j; fi

                    endscope



                    Dyckpath(0,0)(Graph1)[4][4](4)1,1,1,1,0,0,0,0
                    Dyckpath(6,0)(Graph2)[4][4](4)1,1,1,0,1,0,0,0
                    Dyckpath(12,0)(Graph3)[4][4](4)1,1,0,1,1,0,0,0

                    draw[->] (Graph1) -- (Graph2);
                    draw[->] (Graph2) -- (Graph3);

                    Dyckpath(0,-6)(Graph1-b)[3][3](4)1,1,1,0,0,0
                    Dyckpath(0,-10)(Graph1-c)[2][2](4)1,1,0,0

                    draw[->] (Graph1-3) -- ++(0,-1) -| (Graph1-b);
                    draw[->] (Graph1-b-2) |- ++(1.7,-0.5) |- (Graph1-c.0);
                    draw[->,shorten >=15pt] (Graph1-5) -- (Graph1-b-5); %Thanks to max for the observation
                    draw[->,shorten >=15pt] (Graph1-b-4) -- (Graph1-c-4);

                    Dyckpath(6,-6)(Graph2-b)[4][3](5)1,1,0,1,0,0,0
                    Dyckpath(12,-10)(Graph3-b)[3][7](5)1,1,1,1,0,1,1,0,1,0

                    draw[->] (Graph3-b) -| (Graph3-5);

                    endtikzpicture
                    enddocument


                    PSD: I work with standalone document class to work with a precompiled tikz drawing, with the imported pdf format output to the main document inside figure environment to obtain better position control even in landscape pages, tables, etc. like in this post Scaling different components of tikzpicture together.






                    share|improve this answer






















                    • Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
                      – Max
                      Aug 18 at 11:48










                    • Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
                      – J Leon V.
                      Aug 18 at 13:54












                    up vote
                    3
                    down vote










                    up vote
                    3
                    down vote









                    just for fun an adaptation that uses the excellent codes with some additional details according to taste, an arrow for each direction, option to change the size, use the library fit, to generate a node that contains only the grid, in that way the arrows always come from the center of it and it is possible to place a text in the desired position around it, also add names for certain nodes such as the numbers from which you can connect using their names.



                    RESULT:



                    enter image description here



                    MWE:



                    documentclass[border=0pt]standalone
                    usepackagetikz
                    usetikzlibrarybackgrounds,arrows.meta,fit
                    begindocument
                    begintikzpicture[
                    %Environmet config
                    >=Stealth[inset=0pt,length=7pt],
                    %Environment Styles
                    background rectangle/.style=%Seting the background styles
                    fill=brown!50!orange!50,
                    ,
                    show background rectangle, % Indicates to activate the background.
                    ]

                    defDyckpath(#1)(#2)[#3][#4](#5)#6%1:Position, 2: DickpathName, 3: X dimension, 4: Y dimension, 5: X labels 6: moves
                    beginscope[shift=(#1)]
                    draw[black!80,step=1,line width=0.5pt] (0,0) grid (#3,#4);
                    coordinate (temp) at (0,0); node(a) at (0,0); node(b) at (#3,#4);
                    node[fit=(a)(b),label=[anchor=west]north west:#2,inner ysep=10pt](#2);
                    foreach dir in #6
                    draw[->,line width=1.5pt] (temp) -- ++(90*dir:1) coordinate (temp);
                    foreach value [count=j] in 0,1,...,#5
                    ifnumvalue>#3 draw[fill](value,-0.5) node(#2-j) j ++(0,0.5) circle (1pt);
                    else draw[fill](value,-0.5) node(#2-j) j; fi

                    endscope



                    Dyckpath(0,0)(Graph1)[4][4](4)1,1,1,1,0,0,0,0
                    Dyckpath(6,0)(Graph2)[4][4](4)1,1,1,0,1,0,0,0
                    Dyckpath(12,0)(Graph3)[4][4](4)1,1,0,1,1,0,0,0

                    draw[->] (Graph1) -- (Graph2);
                    draw[->] (Graph2) -- (Graph3);

                    Dyckpath(0,-6)(Graph1-b)[3][3](4)1,1,1,0,0,0
                    Dyckpath(0,-10)(Graph1-c)[2][2](4)1,1,0,0

                    draw[->] (Graph1-3) -- ++(0,-1) -| (Graph1-b);
                    draw[->] (Graph1-b-2) |- ++(1.7,-0.5) |- (Graph1-c.0);
                    draw[->,shorten >=15pt] (Graph1-5) -- (Graph1-b-5); %Thanks to max for the observation
                    draw[->,shorten >=15pt] (Graph1-b-4) -- (Graph1-c-4);

                    Dyckpath(6,-6)(Graph2-b)[4][3](5)1,1,0,1,0,0,0
                    Dyckpath(12,-10)(Graph3-b)[3][7](5)1,1,1,1,0,1,1,0,1,0

                    draw[->] (Graph3-b) -| (Graph3-5);

                    endtikzpicture
                    enddocument


                    PSD: I work with standalone document class to work with a precompiled tikz drawing, with the imported pdf format output to the main document inside figure environment to obtain better position control even in landscape pages, tables, etc. like in this post Scaling different components of tikzpicture together.






                    share|improve this answer














                    just for fun an adaptation that uses the excellent codes with some additional details according to taste, an arrow for each direction, option to change the size, use the library fit, to generate a node that contains only the grid, in that way the arrows always come from the center of it and it is possible to place a text in the desired position around it, also add names for certain nodes such as the numbers from which you can connect using their names.



                    RESULT:



                    enter image description here



                    MWE:



                    documentclass[border=0pt]standalone
                    usepackagetikz
                    usetikzlibrarybackgrounds,arrows.meta,fit
                    begindocument
                    begintikzpicture[
                    %Environmet config
                    >=Stealth[inset=0pt,length=7pt],
                    %Environment Styles
                    background rectangle/.style=%Seting the background styles
                    fill=brown!50!orange!50,
                    ,
                    show background rectangle, % Indicates to activate the background.
                    ]

                    defDyckpath(#1)(#2)[#3][#4](#5)#6%1:Position, 2: DickpathName, 3: X dimension, 4: Y dimension, 5: X labels 6: moves
                    beginscope[shift=(#1)]
                    draw[black!80,step=1,line width=0.5pt] (0,0) grid (#3,#4);
                    coordinate (temp) at (0,0); node(a) at (0,0); node(b) at (#3,#4);
                    node[fit=(a)(b),label=[anchor=west]north west:#2,inner ysep=10pt](#2);
                    foreach dir in #6
                    draw[->,line width=1.5pt] (temp) -- ++(90*dir:1) coordinate (temp);
                    foreach value [count=j] in 0,1,...,#5
                    ifnumvalue>#3 draw[fill](value,-0.5) node(#2-j) j ++(0,0.5) circle (1pt);
                    else draw[fill](value,-0.5) node(#2-j) j; fi

                    endscope



                    Dyckpath(0,0)(Graph1)[4][4](4)1,1,1,1,0,0,0,0
                    Dyckpath(6,0)(Graph2)[4][4](4)1,1,1,0,1,0,0,0
                    Dyckpath(12,0)(Graph3)[4][4](4)1,1,0,1,1,0,0,0

                    draw[->] (Graph1) -- (Graph2);
                    draw[->] (Graph2) -- (Graph3);

                    Dyckpath(0,-6)(Graph1-b)[3][3](4)1,1,1,0,0,0
                    Dyckpath(0,-10)(Graph1-c)[2][2](4)1,1,0,0

                    draw[->] (Graph1-3) -- ++(0,-1) -| (Graph1-b);
                    draw[->] (Graph1-b-2) |- ++(1.7,-0.5) |- (Graph1-c.0);
                    draw[->,shorten >=15pt] (Graph1-5) -- (Graph1-b-5); %Thanks to max for the observation
                    draw[->,shorten >=15pt] (Graph1-b-4) -- (Graph1-c-4);

                    Dyckpath(6,-6)(Graph2-b)[4][3](5)1,1,0,1,0,0,0
                    Dyckpath(12,-10)(Graph3-b)[3][7](5)1,1,1,1,0,1,1,0,1,0

                    draw[->] (Graph3-b) -| (Graph3-5);

                    endtikzpicture
                    enddocument


                    PSD: I work with standalone document class to work with a precompiled tikz drawing, with the imported pdf format output to the main document inside figure environment to obtain better position control even in landscape pages, tables, etc. like in this post Scaling different components of tikzpicture together.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 18 at 13:55

























                    answered Aug 17 at 17:55









                    J Leon V.

                    6,121527




                    6,121527











                    • Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
                      – Max
                      Aug 18 at 11:48










                    • Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
                      – J Leon V.
                      Aug 18 at 13:54
















                    • Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
                      – Max
                      Aug 18 at 11:48










                    • Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
                      – J Leon V.
                      Aug 18 at 13:54















                    Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
                    – Max
                    Aug 18 at 11:48




                    Very nice, +1! One small question, why do you use relative positioning with predefined coordinates/nodes (e.g. in draw[->,shorten >=15pt] (Graph1-b-4) -- ++(Graph1-c-4);)?
                    – Max
                    Aug 18 at 11:48












                    Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
                    – J Leon V.
                    Aug 18 at 13:54




                    Oh, well, it's because it's a mistake, I do not understand why the result is similar to the correct form, I'll correct it.
                    – J Leon V.
                    Aug 18 at 13:54

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f446410%2fdyck-paths-behaving-as-nodes%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    One-line joke