Dyck paths with extra diagonals from valleys (Laser construction)Drawing paths with TikZ from a DB with DataToolconstruction set of treeTikZ reusable paths with variablesNumerical conditional within tikz keys?How to draw points in TikZ?Line up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?Help needed with drawing diagonals over the pageHow to split a (Hobby) path in twoIntersection between paths from different axis environments

What term is being referred to with "reflected-sound-of-underground-spirits"?

Check if a string is entirely made of the same substring

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

As an international instructor, should I openly talk about my accent?

Why did C use the -> operator instead of reusing the . operator?

Why does Mind Blank stop the Feeblemind spell?

Was Dennis Ritchie being too modest in this quote about C and Pascal?

How did Captain America manage to do this?

How to write a column outside the braces in a matrix?

Contradiction proof for inequality of P and NP?

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

Can I criticise the more senior developers around me for not writing clean code?

If a planet has 3 moons, is it possible to have triple Full/New Moons at once?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

Which big number is bigger?

Dynamic SOQL query relationship with field visibility for Users

How to limit Drive Letters Windows assigns to new removable USB drives

How can I practically buy stocks?

Solving polynominals equations (relationship of roots)

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

How to pronounce 'c++' in Spanish

Phrase for the opposite of "foolproof"

Checks user level and limit the data before saving it to mongoDB

"The cow" OR "a cow" OR "cows" in this context



Dyck paths with extra diagonals from valleys (Laser construction)


Drawing paths with TikZ from a DB with DataToolconstruction set of treeTikZ reusable paths with variablesNumerical conditional within tikz keys?How to draw points in TikZ?Line up nested tikz enviroments or how to get rid of themHow to draw a square and its diagonals with arrows?Help needed with drawing diagonals over the pageHow to split a (Hobby) path in twoIntersection between paths from different axis environments













4















I would like to create a Dyck path in Latex with two additional features. First, I would like to number all the East step except(!) for the last one. Secondly, for each valley (that is, an East step that is followed by a North step), I would like to draw "lasers" which would be lines that are parallel to the diagonal and that stops once it reaches the Dyck path. This is similar, but not exactly the same as the "laser construction" in this paper. See e.g. Figure 6.



I already have some code to obtain a Dyck path.



documentclassarticle
usepackagetikz

newcommandNEpath[4]
fill[white!25] (#1) rectangle +(#2,#3);
fill[fill=white]
(#1)
foreach dir in #4
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
begintikzpicture
NEpath0,0661,1,0,1,1,0,0,0,1,0,1,0;
endtikzpicture
enddocument


which produces the following picture.



enter image description here



Whereas I would like to obtain something like



enter image description here



Is it be possible to modify my existing code to obtain what I desire? If not, is there an alternative approach?










share|improve this question






















  • How about adding those paths manually?

    – JouleV
    Apr 19 at 14:41











  • Btw, as it is an arXiv document, you may find the source code of the file, thus you can find the code for the picture

    – JouleV
    Apr 19 at 14:42











  • @JouleV I am unfortunately not very good with tikz - what do you mean by adding the paths manually? Also, the image in the pdf is not done in tikz but rather attached as a pdf.

    – Joakim Uhlin
    Apr 19 at 14:59






  • 1





    What I mean is that you can add the lines "by hand" inside the tikzpicture

    – JouleV
    Apr 19 at 15:02















4















I would like to create a Dyck path in Latex with two additional features. First, I would like to number all the East step except(!) for the last one. Secondly, for each valley (that is, an East step that is followed by a North step), I would like to draw "lasers" which would be lines that are parallel to the diagonal and that stops once it reaches the Dyck path. This is similar, but not exactly the same as the "laser construction" in this paper. See e.g. Figure 6.



I already have some code to obtain a Dyck path.



documentclassarticle
usepackagetikz

newcommandNEpath[4]
fill[white!25] (#1) rectangle +(#2,#3);
fill[fill=white]
(#1)
foreach dir in #4
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
begintikzpicture
NEpath0,0661,1,0,1,1,0,0,0,1,0,1,0;
endtikzpicture
enddocument


which produces the following picture.



enter image description here



Whereas I would like to obtain something like



enter image description here



Is it be possible to modify my existing code to obtain what I desire? If not, is there an alternative approach?










share|improve this question






















  • How about adding those paths manually?

    – JouleV
    Apr 19 at 14:41











  • Btw, as it is an arXiv document, you may find the source code of the file, thus you can find the code for the picture

    – JouleV
    Apr 19 at 14:42











  • @JouleV I am unfortunately not very good with tikz - what do you mean by adding the paths manually? Also, the image in the pdf is not done in tikz but rather attached as a pdf.

    – Joakim Uhlin
    Apr 19 at 14:59






  • 1





    What I mean is that you can add the lines "by hand" inside the tikzpicture

    – JouleV
    Apr 19 at 15:02













4












4








4


1






I would like to create a Dyck path in Latex with two additional features. First, I would like to number all the East step except(!) for the last one. Secondly, for each valley (that is, an East step that is followed by a North step), I would like to draw "lasers" which would be lines that are parallel to the diagonal and that stops once it reaches the Dyck path. This is similar, but not exactly the same as the "laser construction" in this paper. See e.g. Figure 6.



I already have some code to obtain a Dyck path.



documentclassarticle
usepackagetikz

newcommandNEpath[4]
fill[white!25] (#1) rectangle +(#2,#3);
fill[fill=white]
(#1)
foreach dir in #4
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
begintikzpicture
NEpath0,0661,1,0,1,1,0,0,0,1,0,1,0;
endtikzpicture
enddocument


which produces the following picture.



enter image description here



Whereas I would like to obtain something like



enter image description here



Is it be possible to modify my existing code to obtain what I desire? If not, is there an alternative approach?










share|improve this question














I would like to create a Dyck path in Latex with two additional features. First, I would like to number all the East step except(!) for the last one. Secondly, for each valley (that is, an East step that is followed by a North step), I would like to draw "lasers" which would be lines that are parallel to the diagonal and that stops once it reaches the Dyck path. This is similar, but not exactly the same as the "laser construction" in this paper. See e.g. Figure 6.



I already have some code to obtain a Dyck path.



documentclassarticle
usepackagetikz

newcommandNEpath[4]
fill[white!25] (#1) rectangle +(#2,#3);
fill[fill=white]
(#1)
foreach dir in #4
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
begintikzpicture
NEpath0,0661,1,0,1,1,0,0,0,1,0,1,0;
endtikzpicture
enddocument


which produces the following picture.



enter image description here



Whereas I would like to obtain something like



enter image description here



Is it be possible to modify my existing code to obtain what I desire? If not, is there an alternative approach?







tikz-pgf






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 19 at 14:38









Joakim UhlinJoakim Uhlin

1347




1347












  • How about adding those paths manually?

    – JouleV
    Apr 19 at 14:41











  • Btw, as it is an arXiv document, you may find the source code of the file, thus you can find the code for the picture

    – JouleV
    Apr 19 at 14:42











  • @JouleV I am unfortunately not very good with tikz - what do you mean by adding the paths manually? Also, the image in the pdf is not done in tikz but rather attached as a pdf.

    – Joakim Uhlin
    Apr 19 at 14:59






  • 1





    What I mean is that you can add the lines "by hand" inside the tikzpicture

    – JouleV
    Apr 19 at 15:02

















  • How about adding those paths manually?

    – JouleV
    Apr 19 at 14:41











  • Btw, as it is an arXiv document, you may find the source code of the file, thus you can find the code for the picture

    – JouleV
    Apr 19 at 14:42











  • @JouleV I am unfortunately not very good with tikz - what do you mean by adding the paths manually? Also, the image in the pdf is not done in tikz but rather attached as a pdf.

    – Joakim Uhlin
    Apr 19 at 14:59






  • 1





    What I mean is that you can add the lines "by hand" inside the tikzpicture

    – JouleV
    Apr 19 at 15:02
















How about adding those paths manually?

– JouleV
Apr 19 at 14:41





How about adding those paths manually?

– JouleV
Apr 19 at 14:41













Btw, as it is an arXiv document, you may find the source code of the file, thus you can find the code for the picture

– JouleV
Apr 19 at 14:42





Btw, as it is an arXiv document, you may find the source code of the file, thus you can find the code for the picture

– JouleV
Apr 19 at 14:42













@JouleV I am unfortunately not very good with tikz - what do you mean by adding the paths manually? Also, the image in the pdf is not done in tikz but rather attached as a pdf.

– Joakim Uhlin
Apr 19 at 14:59





@JouleV I am unfortunately not very good with tikz - what do you mean by adding the paths manually? Also, the image in the pdf is not done in tikz but rather attached as a pdf.

– Joakim Uhlin
Apr 19 at 14:59




1




1





What I mean is that you can add the lines "by hand" inside the tikzpicture

– JouleV
Apr 19 at 15:02





What I mean is that you can add the lines "by hand" inside the tikzpicture

– JouleV
Apr 19 at 15:02










3 Answers
3






active

oldest

votes


















5














Just for fun, something that adds the numbers and laser lines automatically. The laser lines are drawn automatically according to your clarified prescription. The strategy is to look at the elements of the list that are ahead and check whether or not they fulfill certain criteria. The integer vtest tests if the current point is a "valley", in which case it is 10, and the other integers are constructed similarly.



documentclass[tikz,border=3.14mm]standalone
newcounterDyckHsteps
begindocument
tikzsetcount list/.code 2 args=foreach XX [count=YY] in #1
xdef#2YY,Dyck arrow/.style=ultra thick,-stealth,
laser/.style=draw=blue,
Dyck path/.style=count list=#1DyckSteps,
/utils/exec=setcounterDyckHsteps0,insert path=%
foreach XX [count=YY,remember=YY as LastY (initially 0)]in #1
ifnumXX=0
edge[Dyck arrow] ++(1,0) ++(1,0) coordinate(Dyck-YY)
ifnumYY<DyckSteps
(Dyck-LastY) -- (Dyck-YY) node[midway,above]stepcounterDyckHstepsnumbervalueDyckHsteps
fi
else
edge[Dyck arrow] ++(0,1) ++(0,1) coordinate(Dyck-YY)
fi
pgfextrapgfmathtruncatemacrovtest0pgfmathtruncatemacroftest0pgfmathtruncatemacrohtest0pgfmathtruncatemacroitest1
pgfmathtruncatemacroRestStepsDyckSteps-YY
ifnumYY>1
ifnumRestSteps>1
pgfmathtruncatemacroftest#1[YY+1]+#1[YY]*10 % should be 10
pgfmathtruncatemacrovtest#1[YY-1]+10*#1[YY] % valley test
fi
ifnumRestSteps>3
pgfmathtruncatemacrohtestpow(-1,#1[YY+3])+pow(-1,#1[YY+2])
+pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0))
fi
ifnumRestSteps>5
pgfmathtruncatemacroitestpow(-1,#1[YY+5])+
pow(-1,#1[YY+4])+pow(-1,#1[YY+3])+pow(-1,#1[YY+2])
+pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0)
+ifthenelse(#1[YY-2]==1,11,0)
fi
fi%typeoutYY:RestSteps:ftest,htest,itest,vtest

ifnumvtest=10
%(Dyck-YY) node[blue,fill,circle,inner sep=2pt](Dyck-YY)
ifnumitest=0
(Dyck-YY) edge[laser] ++(3,3) (Dyck-YY)
fi
ifnumhtest=1100
(Dyck-YY) edge[laser] ++(-2,-2) (Dyck-YY)
fi
ifnumftest=10
(Dyck-YY) edge[laser] ++(1,1) (Dyck-YY)
fi
fi

begintikzpicture
draw (0,0) grid (6,6);
draw (0,0) [Dyck path=1,1,0,1,0,0,1,1,0,1,0,0];
endtikzpicture
enddocument


enter image description here






share|improve this answer

























  • Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

    – Joakim Uhlin
    Apr 19 at 17:06











  • @JoakimUhlin They go right-up, don't they?

    – marmot
    Apr 19 at 17:08











  • True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

    – Joakim Uhlin
    Apr 19 at 17:12












  • @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

    – marmot
    Apr 19 at 17:16






  • 1





    @JoakimUhlin I updated the answer accordingly.

    – marmot
    Apr 19 at 18:16


















6














With the help from JouleV, I managed to do solve this but I am leaving this as an answer for people who might be interested.



documentclassarticle
usepackagetikz

newcommandNEpath[4]
fill[white!25] (#1) rectangle +(#2,#3);
fill[fill=white]
(#1)
foreach dir in #4
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
begintikzpicture
NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
draw (1,2) -- +(1,1);
draw (3,3.1) -- +(2.9,2.9);
draw (4,5) -- +(1,1);
node at (0.5, 2.5) 1;
node at (1.5, 3.5) 2;
node at (2.5, 3.5) 3;
node at (3.5, 5.5) 4;
node at (4.5, 6.5) 5;
endtikzpicture
enddocument


This produces the following the picture



enter image description here



Perhaps not the most pretty solution and quite mechanical but it works for my purposes. However, It would still be interesting to have a more general solution so that I would not need to draw lines and numbers manually.






share|improve this answer


















  • 1





    I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

    – nomen
    Apr 19 at 22:22


















5














First, congratulations for figuring out everything by yourself. I upvoted your answer.



This answer is a slight improvement of your answer in the position of the nodes (the numbers). I use option above to have a better space between the number and the line below it.



documentclassarticle
usepackagetikz

newcommandNEpath[4]
fill[white!25] (#1) rectangle +(#2,#3);
fill[fill=white]
(#1)
foreach dir in #4
ifnumdir=0
-- ++(1,0)
else
-- ++(0,1)
fi


begindocument
begintikzpicture
NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
draw (1,2) -- +(1,1);
draw (3,3.1) -- +(2.9,2.9);
draw (4,5) -- +(1,1);
node[above=2pt] at (0.5, 2) 1;
node[above=2pt] at (1.5, 3) 2;
node[above=2pt] at (2.5, 3) 3;
node[above=2pt] at (3.5, 5) 4;
node[above=2pt] at (4.5, 6) 5;
endtikzpicture
enddocument


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



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f485606%2fdyck-paths-with-extra-diagonals-from-valleys-laser-construction%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    Just for fun, something that adds the numbers and laser lines automatically. The laser lines are drawn automatically according to your clarified prescription. The strategy is to look at the elements of the list that are ahead and check whether or not they fulfill certain criteria. The integer vtest tests if the current point is a "valley", in which case it is 10, and the other integers are constructed similarly.



    documentclass[tikz,border=3.14mm]standalone
    newcounterDyckHsteps
    begindocument
    tikzsetcount list/.code 2 args=foreach XX [count=YY] in #1
    xdef#2YY,Dyck arrow/.style=ultra thick,-stealth,
    laser/.style=draw=blue,
    Dyck path/.style=count list=#1DyckSteps,
    /utils/exec=setcounterDyckHsteps0,insert path=%
    foreach XX [count=YY,remember=YY as LastY (initially 0)]in #1
    ifnumXX=0
    edge[Dyck arrow] ++(1,0) ++(1,0) coordinate(Dyck-YY)
    ifnumYY<DyckSteps
    (Dyck-LastY) -- (Dyck-YY) node[midway,above]stepcounterDyckHstepsnumbervalueDyckHsteps
    fi
    else
    edge[Dyck arrow] ++(0,1) ++(0,1) coordinate(Dyck-YY)
    fi
    pgfextrapgfmathtruncatemacrovtest0pgfmathtruncatemacroftest0pgfmathtruncatemacrohtest0pgfmathtruncatemacroitest1
    pgfmathtruncatemacroRestStepsDyckSteps-YY
    ifnumYY>1
    ifnumRestSteps>1
    pgfmathtruncatemacroftest#1[YY+1]+#1[YY]*10 % should be 10
    pgfmathtruncatemacrovtest#1[YY-1]+10*#1[YY] % valley test
    fi
    ifnumRestSteps>3
    pgfmathtruncatemacrohtestpow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0))
    fi
    ifnumRestSteps>5
    pgfmathtruncatemacroitestpow(-1,#1[YY+5])+
    pow(-1,#1[YY+4])+pow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0)
    +ifthenelse(#1[YY-2]==1,11,0)
    fi
    fi%typeoutYY:RestSteps:ftest,htest,itest,vtest

    ifnumvtest=10
    %(Dyck-YY) node[blue,fill,circle,inner sep=2pt](Dyck-YY)
    ifnumitest=0
    (Dyck-YY) edge[laser] ++(3,3) (Dyck-YY)
    fi
    ifnumhtest=1100
    (Dyck-YY) edge[laser] ++(-2,-2) (Dyck-YY)
    fi
    ifnumftest=10
    (Dyck-YY) edge[laser] ++(1,1) (Dyck-YY)
    fi
    fi

    begintikzpicture
    draw (0,0) grid (6,6);
    draw (0,0) [Dyck path=1,1,0,1,0,0,1,1,0,1,0,0];
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























    • Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

      – Joakim Uhlin
      Apr 19 at 17:06











    • @JoakimUhlin They go right-up, don't they?

      – marmot
      Apr 19 at 17:08











    • True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

      – Joakim Uhlin
      Apr 19 at 17:12












    • @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

      – marmot
      Apr 19 at 17:16






    • 1





      @JoakimUhlin I updated the answer accordingly.

      – marmot
      Apr 19 at 18:16















    5














    Just for fun, something that adds the numbers and laser lines automatically. The laser lines are drawn automatically according to your clarified prescription. The strategy is to look at the elements of the list that are ahead and check whether or not they fulfill certain criteria. The integer vtest tests if the current point is a "valley", in which case it is 10, and the other integers are constructed similarly.



    documentclass[tikz,border=3.14mm]standalone
    newcounterDyckHsteps
    begindocument
    tikzsetcount list/.code 2 args=foreach XX [count=YY] in #1
    xdef#2YY,Dyck arrow/.style=ultra thick,-stealth,
    laser/.style=draw=blue,
    Dyck path/.style=count list=#1DyckSteps,
    /utils/exec=setcounterDyckHsteps0,insert path=%
    foreach XX [count=YY,remember=YY as LastY (initially 0)]in #1
    ifnumXX=0
    edge[Dyck arrow] ++(1,0) ++(1,0) coordinate(Dyck-YY)
    ifnumYY<DyckSteps
    (Dyck-LastY) -- (Dyck-YY) node[midway,above]stepcounterDyckHstepsnumbervalueDyckHsteps
    fi
    else
    edge[Dyck arrow] ++(0,1) ++(0,1) coordinate(Dyck-YY)
    fi
    pgfextrapgfmathtruncatemacrovtest0pgfmathtruncatemacroftest0pgfmathtruncatemacrohtest0pgfmathtruncatemacroitest1
    pgfmathtruncatemacroRestStepsDyckSteps-YY
    ifnumYY>1
    ifnumRestSteps>1
    pgfmathtruncatemacroftest#1[YY+1]+#1[YY]*10 % should be 10
    pgfmathtruncatemacrovtest#1[YY-1]+10*#1[YY] % valley test
    fi
    ifnumRestSteps>3
    pgfmathtruncatemacrohtestpow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0))
    fi
    ifnumRestSteps>5
    pgfmathtruncatemacroitestpow(-1,#1[YY+5])+
    pow(-1,#1[YY+4])+pow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0)
    +ifthenelse(#1[YY-2]==1,11,0)
    fi
    fi%typeoutYY:RestSteps:ftest,htest,itest,vtest

    ifnumvtest=10
    %(Dyck-YY) node[blue,fill,circle,inner sep=2pt](Dyck-YY)
    ifnumitest=0
    (Dyck-YY) edge[laser] ++(3,3) (Dyck-YY)
    fi
    ifnumhtest=1100
    (Dyck-YY) edge[laser] ++(-2,-2) (Dyck-YY)
    fi
    ifnumftest=10
    (Dyck-YY) edge[laser] ++(1,1) (Dyck-YY)
    fi
    fi

    begintikzpicture
    draw (0,0) grid (6,6);
    draw (0,0) [Dyck path=1,1,0,1,0,0,1,1,0,1,0,0];
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























    • Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

      – Joakim Uhlin
      Apr 19 at 17:06











    • @JoakimUhlin They go right-up, don't they?

      – marmot
      Apr 19 at 17:08











    • True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

      – Joakim Uhlin
      Apr 19 at 17:12












    • @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

      – marmot
      Apr 19 at 17:16






    • 1





      @JoakimUhlin I updated the answer accordingly.

      – marmot
      Apr 19 at 18:16













    5












    5








    5







    Just for fun, something that adds the numbers and laser lines automatically. The laser lines are drawn automatically according to your clarified prescription. The strategy is to look at the elements of the list that are ahead and check whether or not they fulfill certain criteria. The integer vtest tests if the current point is a "valley", in which case it is 10, and the other integers are constructed similarly.



    documentclass[tikz,border=3.14mm]standalone
    newcounterDyckHsteps
    begindocument
    tikzsetcount list/.code 2 args=foreach XX [count=YY] in #1
    xdef#2YY,Dyck arrow/.style=ultra thick,-stealth,
    laser/.style=draw=blue,
    Dyck path/.style=count list=#1DyckSteps,
    /utils/exec=setcounterDyckHsteps0,insert path=%
    foreach XX [count=YY,remember=YY as LastY (initially 0)]in #1
    ifnumXX=0
    edge[Dyck arrow] ++(1,0) ++(1,0) coordinate(Dyck-YY)
    ifnumYY<DyckSteps
    (Dyck-LastY) -- (Dyck-YY) node[midway,above]stepcounterDyckHstepsnumbervalueDyckHsteps
    fi
    else
    edge[Dyck arrow] ++(0,1) ++(0,1) coordinate(Dyck-YY)
    fi
    pgfextrapgfmathtruncatemacrovtest0pgfmathtruncatemacroftest0pgfmathtruncatemacrohtest0pgfmathtruncatemacroitest1
    pgfmathtruncatemacroRestStepsDyckSteps-YY
    ifnumYY>1
    ifnumRestSteps>1
    pgfmathtruncatemacroftest#1[YY+1]+#1[YY]*10 % should be 10
    pgfmathtruncatemacrovtest#1[YY-1]+10*#1[YY] % valley test
    fi
    ifnumRestSteps>3
    pgfmathtruncatemacrohtestpow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0))
    fi
    ifnumRestSteps>5
    pgfmathtruncatemacroitestpow(-1,#1[YY+5])+
    pow(-1,#1[YY+4])+pow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0)
    +ifthenelse(#1[YY-2]==1,11,0)
    fi
    fi%typeoutYY:RestSteps:ftest,htest,itest,vtest

    ifnumvtest=10
    %(Dyck-YY) node[blue,fill,circle,inner sep=2pt](Dyck-YY)
    ifnumitest=0
    (Dyck-YY) edge[laser] ++(3,3) (Dyck-YY)
    fi
    ifnumhtest=1100
    (Dyck-YY) edge[laser] ++(-2,-2) (Dyck-YY)
    fi
    ifnumftest=10
    (Dyck-YY) edge[laser] ++(1,1) (Dyck-YY)
    fi
    fi

    begintikzpicture
    draw (0,0) grid (6,6);
    draw (0,0) [Dyck path=1,1,0,1,0,0,1,1,0,1,0,0];
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer















    Just for fun, something that adds the numbers and laser lines automatically. The laser lines are drawn automatically according to your clarified prescription. The strategy is to look at the elements of the list that are ahead and check whether or not they fulfill certain criteria. The integer vtest tests if the current point is a "valley", in which case it is 10, and the other integers are constructed similarly.



    documentclass[tikz,border=3.14mm]standalone
    newcounterDyckHsteps
    begindocument
    tikzsetcount list/.code 2 args=foreach XX [count=YY] in #1
    xdef#2YY,Dyck arrow/.style=ultra thick,-stealth,
    laser/.style=draw=blue,
    Dyck path/.style=count list=#1DyckSteps,
    /utils/exec=setcounterDyckHsteps0,insert path=%
    foreach XX [count=YY,remember=YY as LastY (initially 0)]in #1
    ifnumXX=0
    edge[Dyck arrow] ++(1,0) ++(1,0) coordinate(Dyck-YY)
    ifnumYY<DyckSteps
    (Dyck-LastY) -- (Dyck-YY) node[midway,above]stepcounterDyckHstepsnumbervalueDyckHsteps
    fi
    else
    edge[Dyck arrow] ++(0,1) ++(0,1) coordinate(Dyck-YY)
    fi
    pgfextrapgfmathtruncatemacrovtest0pgfmathtruncatemacroftest0pgfmathtruncatemacrohtest0pgfmathtruncatemacroitest1
    pgfmathtruncatemacroRestStepsDyckSteps-YY
    ifnumYY>1
    ifnumRestSteps>1
    pgfmathtruncatemacroftest#1[YY+1]+#1[YY]*10 % should be 10
    pgfmathtruncatemacrovtest#1[YY-1]+10*#1[YY] % valley test
    fi
    ifnumRestSteps>3
    pgfmathtruncatemacrohtestpow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0))
    fi
    ifnumRestSteps>5
    pgfmathtruncatemacroitestpow(-1,#1[YY+5])+
    pow(-1,#1[YY+4])+pow(-1,#1[YY+3])+pow(-1,#1[YY+2])
    +pow(-1,#1[YY+1])+pow(-1,#1[YY])+ifthenelse(#1[YY-1]==1,11,0)
    +ifthenelse(#1[YY-2]==1,11,0)
    fi
    fi%typeoutYY:RestSteps:ftest,htest,itest,vtest

    ifnumvtest=10
    %(Dyck-YY) node[blue,fill,circle,inner sep=2pt](Dyck-YY)
    ifnumitest=0
    (Dyck-YY) edge[laser] ++(3,3) (Dyck-YY)
    fi
    ifnumhtest=1100
    (Dyck-YY) edge[laser] ++(-2,-2) (Dyck-YY)
    fi
    ifnumftest=10
    (Dyck-YY) edge[laser] ++(1,1) (Dyck-YY)
    fi
    fi

    begintikzpicture
    draw (0,0) grid (6,6);
    draw (0,0) [Dyck path=1,1,0,1,0,0,1,1,0,1,0,0];
    endtikzpicture
    enddocument


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 19 at 18:16

























    answered Apr 19 at 16:55









    marmotmarmot

    121k6159297




    121k6159297












    • Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

      – Joakim Uhlin
      Apr 19 at 17:06











    • @JoakimUhlin They go right-up, don't they?

      – marmot
      Apr 19 at 17:08











    • True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

      – Joakim Uhlin
      Apr 19 at 17:12












    • @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

      – marmot
      Apr 19 at 17:16






    • 1





      @JoakimUhlin I updated the answer accordingly.

      – marmot
      Apr 19 at 18:16

















    • Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

      – Joakim Uhlin
      Apr 19 at 17:06











    • @JoakimUhlin They go right-up, don't they?

      – marmot
      Apr 19 at 17:08











    • True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

      – Joakim Uhlin
      Apr 19 at 17:12












    • @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

      – marmot
      Apr 19 at 17:16






    • 1





      @JoakimUhlin I updated the answer accordingly.

      – marmot
      Apr 19 at 18:16
















    Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

    – Joakim Uhlin
    Apr 19 at 17:06





    Nice! But (at least in my case) the lasers should only go from the valleys and up-right. I imagine one could modify the code to get this tho.

    – Joakim Uhlin
    Apr 19 at 17:06













    @JoakimUhlin They go right-up, don't they?

    – marmot
    Apr 19 at 17:08





    @JoakimUhlin They go right-up, don't they?

    – marmot
    Apr 19 at 17:08













    True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

    – Joakim Uhlin
    Apr 19 at 17:12






    True but they also go down-left in your case. You can compare this to my picture. For example, there should not be a laser between (0,0) and (3,3) but there should be one between (3,3) and (6,6).

    – Joakim Uhlin
    Apr 19 at 17:12














    @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

    – marmot
    Apr 19 at 17:16





    @JoakimUhlin Hmm, sorry, I do not understand these prescriptions. Whether it is up-right or down-left is only a matter of perspective, isn't it? From the point (0,0) you can go up-right to (3,3), or you can go from (3,3) down-left to (0,0), the result looks identical to me.

    – marmot
    Apr 19 at 17:16




    1




    1





    @JoakimUhlin I updated the answer accordingly.

    – marmot
    Apr 19 at 18:16





    @JoakimUhlin I updated the answer accordingly.

    – marmot
    Apr 19 at 18:16











    6














    With the help from JouleV, I managed to do solve this but I am leaving this as an answer for people who might be interested.



    documentclassarticle
    usepackagetikz

    newcommandNEpath[4]
    fill[white!25] (#1) rectangle +(#2,#3);
    fill[fill=white]
    (#1)
    foreach dir in #4
    ifnumdir=0
    -- ++(1,0)
    else
    -- ++(0,1)
    fi


    begindocument
    begintikzpicture
    NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
    draw (1,2) -- +(1,1);
    draw (3,3.1) -- +(2.9,2.9);
    draw (4,5) -- +(1,1);
    node at (0.5, 2.5) 1;
    node at (1.5, 3.5) 2;
    node at (2.5, 3.5) 3;
    node at (3.5, 5.5) 4;
    node at (4.5, 6.5) 5;
    endtikzpicture
    enddocument


    This produces the following the picture



    enter image description here



    Perhaps not the most pretty solution and quite mechanical but it works for my purposes. However, It would still be interesting to have a more general solution so that I would not need to draw lines and numbers manually.






    share|improve this answer


















    • 1





      I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

      – nomen
      Apr 19 at 22:22















    6














    With the help from JouleV, I managed to do solve this but I am leaving this as an answer for people who might be interested.



    documentclassarticle
    usepackagetikz

    newcommandNEpath[4]
    fill[white!25] (#1) rectangle +(#2,#3);
    fill[fill=white]
    (#1)
    foreach dir in #4
    ifnumdir=0
    -- ++(1,0)
    else
    -- ++(0,1)
    fi


    begindocument
    begintikzpicture
    NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
    draw (1,2) -- +(1,1);
    draw (3,3.1) -- +(2.9,2.9);
    draw (4,5) -- +(1,1);
    node at (0.5, 2.5) 1;
    node at (1.5, 3.5) 2;
    node at (2.5, 3.5) 3;
    node at (3.5, 5.5) 4;
    node at (4.5, 6.5) 5;
    endtikzpicture
    enddocument


    This produces the following the picture



    enter image description here



    Perhaps not the most pretty solution and quite mechanical but it works for my purposes. However, It would still be interesting to have a more general solution so that I would not need to draw lines and numbers manually.






    share|improve this answer


















    • 1





      I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

      – nomen
      Apr 19 at 22:22













    6












    6








    6







    With the help from JouleV, I managed to do solve this but I am leaving this as an answer for people who might be interested.



    documentclassarticle
    usepackagetikz

    newcommandNEpath[4]
    fill[white!25] (#1) rectangle +(#2,#3);
    fill[fill=white]
    (#1)
    foreach dir in #4
    ifnumdir=0
    -- ++(1,0)
    else
    -- ++(0,1)
    fi


    begindocument
    begintikzpicture
    NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
    draw (1,2) -- +(1,1);
    draw (3,3.1) -- +(2.9,2.9);
    draw (4,5) -- +(1,1);
    node at (0.5, 2.5) 1;
    node at (1.5, 3.5) 2;
    node at (2.5, 3.5) 3;
    node at (3.5, 5.5) 4;
    node at (4.5, 6.5) 5;
    endtikzpicture
    enddocument


    This produces the following the picture



    enter image description here



    Perhaps not the most pretty solution and quite mechanical but it works for my purposes. However, It would still be interesting to have a more general solution so that I would not need to draw lines and numbers manually.






    share|improve this answer













    With the help from JouleV, I managed to do solve this but I am leaving this as an answer for people who might be interested.



    documentclassarticle
    usepackagetikz

    newcommandNEpath[4]
    fill[white!25] (#1) rectangle +(#2,#3);
    fill[fill=white]
    (#1)
    foreach dir in #4
    ifnumdir=0
    -- ++(1,0)
    else
    -- ++(0,1)
    fi


    begindocument
    begintikzpicture
    NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
    draw (1,2) -- +(1,1);
    draw (3,3.1) -- +(2.9,2.9);
    draw (4,5) -- +(1,1);
    node at (0.5, 2.5) 1;
    node at (1.5, 3.5) 2;
    node at (2.5, 3.5) 3;
    node at (3.5, 5.5) 4;
    node at (4.5, 6.5) 5;
    endtikzpicture
    enddocument


    This produces the following the picture



    enter image description here



    Perhaps not the most pretty solution and quite mechanical but it works for my purposes. However, It would still be interesting to have a more general solution so that I would not need to draw lines and numbers manually.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Apr 19 at 15:24









    Joakim UhlinJoakim Uhlin

    1347




    1347







    • 1





      I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

      – nomen
      Apr 19 at 22:22












    • 1





      I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

      – nomen
      Apr 19 at 22:22







    1




    1





    I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

    – nomen
    Apr 19 at 22:22





    I think this is going to be the most general solution unless someone comes up with a tikz package for drawing your specific kind of graph/path.

    – nomen
    Apr 19 at 22:22











    5














    First, congratulations for figuring out everything by yourself. I upvoted your answer.



    This answer is a slight improvement of your answer in the position of the nodes (the numbers). I use option above to have a better space between the number and the line below it.



    documentclassarticle
    usepackagetikz

    newcommandNEpath[4]
    fill[white!25] (#1) rectangle +(#2,#3);
    fill[fill=white]
    (#1)
    foreach dir in #4
    ifnumdir=0
    -- ++(1,0)
    else
    -- ++(0,1)
    fi


    begindocument
    begintikzpicture
    NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
    draw (1,2) -- +(1,1);
    draw (3,3.1) -- +(2.9,2.9);
    draw (4,5) -- +(1,1);
    node[above=2pt] at (0.5, 2) 1;
    node[above=2pt] at (1.5, 3) 2;
    node[above=2pt] at (2.5, 3) 3;
    node[above=2pt] at (3.5, 5) 4;
    node[above=2pt] at (4.5, 6) 5;
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer



























      5














      First, congratulations for figuring out everything by yourself. I upvoted your answer.



      This answer is a slight improvement of your answer in the position of the nodes (the numbers). I use option above to have a better space between the number and the line below it.



      documentclassarticle
      usepackagetikz

      newcommandNEpath[4]
      fill[white!25] (#1) rectangle +(#2,#3);
      fill[fill=white]
      (#1)
      foreach dir in #4
      ifnumdir=0
      -- ++(1,0)
      else
      -- ++(0,1)
      fi


      begindocument
      begintikzpicture
      NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
      draw (1,2) -- +(1,1);
      draw (3,3.1) -- +(2.9,2.9);
      draw (4,5) -- +(1,1);
      node[above=2pt] at (0.5, 2) 1;
      node[above=2pt] at (1.5, 3) 2;
      node[above=2pt] at (2.5, 3) 3;
      node[above=2pt] at (3.5, 5) 4;
      node[above=2pt] at (4.5, 6) 5;
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer

























        5












        5








        5







        First, congratulations for figuring out everything by yourself. I upvoted your answer.



        This answer is a slight improvement of your answer in the position of the nodes (the numbers). I use option above to have a better space between the number and the line below it.



        documentclassarticle
        usepackagetikz

        newcommandNEpath[4]
        fill[white!25] (#1) rectangle +(#2,#3);
        fill[fill=white]
        (#1)
        foreach dir in #4
        ifnumdir=0
        -- ++(1,0)
        else
        -- ++(0,1)
        fi


        begindocument
        begintikzpicture
        NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
        draw (1,2) -- +(1,1);
        draw (3,3.1) -- +(2.9,2.9);
        draw (4,5) -- +(1,1);
        node[above=2pt] at (0.5, 2) 1;
        node[above=2pt] at (1.5, 3) 2;
        node[above=2pt] at (2.5, 3) 3;
        node[above=2pt] at (3.5, 5) 4;
        node[above=2pt] at (4.5, 6) 5;
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer













        First, congratulations for figuring out everything by yourself. I upvoted your answer.



        This answer is a slight improvement of your answer in the position of the nodes (the numbers). I use option above to have a better space between the number and the line below it.



        documentclassarticle
        usepackagetikz

        newcommandNEpath[4]
        fill[white!25] (#1) rectangle +(#2,#3);
        fill[fill=white]
        (#1)
        foreach dir in #4
        ifnumdir=0
        -- ++(1,0)
        else
        -- ++(0,1)
        fi


        begindocument
        begintikzpicture
        NEpath0,0661,1,0,1,0,0,1,1,0,1,0,0;
        draw (1,2) -- +(1,1);
        draw (3,3.1) -- +(2.9,2.9);
        draw (4,5) -- +(1,1);
        node[above=2pt] at (0.5, 2) 1;
        node[above=2pt] at (1.5, 3) 2;
        node[above=2pt] at (2.5, 3) 3;
        node[above=2pt] at (3.5, 5) 4;
        node[above=2pt] at (4.5, 6) 5;
        endtikzpicture
        enddocument


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 19 at 15:30









        JouleVJouleV

        16.1k22667




        16.1k22667



























            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%2f485606%2fdyck-paths-with-extra-diagonals-from-valleys-laser-construction%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

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company