4

I am a beginner in TikZ and I tried to search for a solution to the best of my ability, but it's just too obscure of a topic to have a proper answer yet. To start off, this is my code:

\begin{tikzpicture}[
    every node/.style = {draw, circle, minimum size = 1cm},
    grow via three points = {one child at (1.25,1.25) and two children at (1.25,1.25) and (2.5,1.25)},
    edge from parent path = {(\tikzparentnode.east) -| (\tikzchildnode.south)}
]
\node{}
child {
    node{}
    child{node{}}
    child{node{}}
    child{node{}}
}
child[missing]{}
child[missing]{}
child[missing]{}
child {
    node{}
    child {
        node{}
        child {node{}}
    }
    child[missing]{}
    child{node{}}
};
\end{tikzpicture}

Here's how it looks like when rendered:

enter image description here

This code was originally more complicated, with lots of repetitive commands, but I managed to simplify it using this convenient child/node syntax. I also tried looking into the forest package, but it didn't seem to allow for these kinds of trees. Anyways, my issue is that the edges have very sharp turns, and I would like to make them more rounded. The following post seems to contain the solution I am seeking, but it didn't work when I tried it: Round corners in connections between nodes

(That is, I tried adding every edge/.style = {draw, rounded corners = 0.5cm},, but it didn't seem to do anything.)

So this is where I am stuck now. I do not want to use any other kind of syntax (more complicated than the node/child one), considering how many of these images I ultimately want to create. The more I can simplify and automate the actual code, the better. I also do not want to rotate or reflect the tree in any way for the sake of migrating over to a different solution (i.e. forests), it must grow from the bottom left and upward. And once more, just to be absolutely clear about what I intend to achieve, here's an illustration, rendered using draw.io:

enter image description here

Thanks for any answers.

1 Answer 1

5

Add the rounded corners option to edge from parent path.

edge from parent path = {[rounded corners=3mm](\tikzparentnode.east) -| (\tikzchildnode.south)}

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}

\begin{tikzpicture}[
    every node/.style = {draw, circle, minimum size = 1cm},
    grow via three points = {one child at (1.25,1.25) and two children at (1.25,1.25) and (2.5,1.25)},
    edge from parent path = {[rounded corners=3mm](\tikzparentnode.east) -| (\tikzchildnode.south)},
]
\node{}
child {
    node{}
    child{node{}}
    child{node{}}
    child{node{}}
}
child[missing]{}
child[missing]{}
child[missing]{}
child {
    node{}
    child {
        node{}
        child {node{}}
    }
    child[missing]{}
    child{node{}}
};
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.