Quantcast
Channel: Antworten auf: Pfeile eines Baumdiagramms beschriften, tikz
Viewing all articles
Browse latest Browse all 3

Antwort von esdd

$
0
0

graph als Alternative

Ab pgf/TikZ Version 3.0 kann man Bäume auch als Graphen zeichnen. Der folgende Code muss dann aber mit LuaLaTeX kompiliert werden:

Open in writeLaTeX
\documentclass[tikz]{standalone}\usetikzlibrary{graphdrawing, graphs,arrows,quotes,babel}\usegdlibrary{trees}\begin{document}\tikz[>=stealth',shorten >=1pt,nodes={fill=white,draw}]\graph[
    tree layout,
    minimum number of children=2,
    level distance=2cm,
    sibling distance=2cm,
    edge quotes={draw=none,auto}
    ]{
    0:0->{
      1:0[>"$p_n$" ']->2:0[>"PFAD" ']->3:0->4:0,
      0:1[>"Pfad"]->{
        1:1->2:1->3:1,
        0:2->{
          1:2->2:2,
          0:3->{1:3,0:4}}}},
    1:0->1:1->1:2->1:3,
    2:0->2:1->2:2,
    3:0->3:1
  };
\end{document}

Ergebnis:

alt text

Das lässt sich dann einigermaßen überschaubar auf mehr Ebenen erweitern:

Open in writeLaTeX
\documentclass[tikz,margin=10pt]{standalone}\usetikzlibrary{graphdrawing, graphs,arrows,quotes,babel}\usegdlibrary{trees}\begin{document}\tikz[>=stealth',shorten >=1pt,nodes={fill=white,draw}]\graph[
    tree layout,
    minimum number of children=2,
    level distance=2cm,
    sibling distance=2cm,
    edge quotes={draw=none,auto}
    ]{
    0:0->{
      1:0[>"$p_n$" ']->2:0[>"PFAD" ']->3:0->4:0->5:0->6:0->7:0->8:0->9:0->10:0,
      0:1[>"Pfad"]->{
        1:1->2:1->3:1->4:1->5:1->6:1->7:1->8:1->9:1,
        0:2->{
          1:2->2:2->3:2->4:2->5:2->6:2->7:2->8:2,
          0:3->{
            1:3->2:3->3:3->4:3->5:3->6:3->7:3,
            0:4->{
              1:4->2:4->3:4->4:4->5:4->6:4,
              0:5->{
                1:5->2:5->3:5->4:5->5:5,
                0:6->{
                  1:6->2:6->3:6->4:6,
                  0:7->{
                    1:7->2:7->3:7,
                    0:8->{
                      1:8->2:8,
                      0:9->{
                        1:9,
                        0:10
                      }}}}}}}}}},
    1:0->1:1->1:2->1:3->1:4->1:5->1:6->1:7->1:8->1:9,
    2:0->2:1->2:2->2:3->2:4->2:5->2:6->2:7->2:8,
    3:0->3:1->3:2->3:3->3:4->3:5->3:6->3:7,
    4:0->4:1->4:2->4:3->4:4->4:5->4:6,
    5:0->5:1->5:2->5:3->5:4->5:5,
    6:0->6:1->6:2->6:3->6:4,
    7:0->7:1->7:2->7:3,
    8:0->8:1->8:2,
    9:0->9:1
  };
\end{document}

Ergebnis:

alt text


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles