Skip to main content
replaced http://tex.stackexchange.com/ with https://tex.stackexchange.com/
Source Link

Edit 1: Here's a variant drawing an arc, it uses Jasper Loy's answer to this questionthis question:

Edit 1: Here's a variant drawing an arc, it uses Jasper Loy's answer to this question:

Edit 1: Here's a variant drawing an arc, it uses Jasper Loy's answer to this question:

added improvement, at least for LTR trees; next: general solution for arbitrary orientation?
Source Link
Tom Bombadil
  • 40.7k
  • 10
  • 137
  • 193

Edit 2: the small gaps in the arcs are due to the fact that always the .center of the nodes is used for computation. For a left-to right graph, this would be better:

\newcommand{\sparc}[8]% vertex, first child, last child, relative radius, text, text options, draw options, shift { \coordinate (firstarm) at ($(#1.east)!#4!(#2.west)$); \coordinate (lastarm) at ($(#1.east)!#4!(#3.west)$); \coordinate (vertex) at (#1.east); \tkzDrawArc[#7](vertex,lastarm)(firstarm) \node[#6] at ($(#1)+(#8)$) {#5}; } 

enter image description here


Edit 2: the small gaps in the arcs are due to the fact that always the .center of the nodes is used for computation. For a left-to right graph, this would be better:

\newcommand{\sparc}[8]% vertex, first child, last child, relative radius, text, text options, draw options, shift { \coordinate (firstarm) at ($(#1.east)!#4!(#2.west)$); \coordinate (lastarm) at ($(#1.east)!#4!(#3.west)$); \coordinate (vertex) at (#1.east); \tkzDrawArc[#7](vertex,lastarm)(firstarm) \node[#6] at ($(#1)+(#8)$) {#5}; } 

enter image description here

added a solution drawing arcs
Source Link
Tom Bombadil
  • 40.7k
  • 10
  • 137
  • 193

Edit 1: Here's a variant drawing an arc, it uses Jasper Loy's answer to this question:

\documentclass{article} \usepackage{tikz-qtree} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{tkz-euclide} \usetkzobj{all} \newcommand{\sparc}[8]% vertex, first child, last child, relative radius, text, text options, draw options, shift { \coordinate (firstarm) at ($(#1)!#4!(#2)$); \coordinate (lastarm) at ($(#1)!#4!(#3)$); \tkzDrawArc[#7](#1,lastarm)(firstarm) \node[#6] at ($(#1)+(#8)$) {#5}; } \begin{document} \begin{tikzpicture}[grow'=right] \tikzset{level distance=2cm} \tikzset{sibling distance=1cm} \tikzset{every tree node/.style={anchor=base west}} \Tree[.\node (a) {a}; [.\node (b) {b}; [.\node (d) {d}; ] [.\node (e) {e}; ] [.\node (e2) {e$_2$}; ] [.\node (e3) {e$_3$}; ] ] [.\node (c) {c}; [.\node (f) {f}; ] [.\node (g) {g}; ] [.\node (h) {h}; ] ] ] \sparc{a}{b}{c}{0.7}{OR}{red}{ultra thick,color=blue!50!cyan}{1.5,0} \sparc{b}{d}{e3}{0.6}{AND}{yellow,circle,fill=green!50!gray}{ultra thick,color=red!50!orange}{1,0} \sparc{c}{f}{h}{0.6}{OR}{blue,circle,fill=blue!50!gray,fill opacity=0.3,text opacity=1}{ultra thick,color=green!30!gray}{1,0} \end{tikzpicture} \end{document} 

enter image description here


Edit 1: Here's a variant drawing an arc, it uses Jasper Loy's answer to this question:

\documentclass{article} \usepackage{tikz-qtree} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{tkz-euclide} \usetkzobj{all} \newcommand{\sparc}[8]% vertex, first child, last child, relative radius, text, text options, draw options, shift { \coordinate (firstarm) at ($(#1)!#4!(#2)$); \coordinate (lastarm) at ($(#1)!#4!(#3)$); \tkzDrawArc[#7](#1,lastarm)(firstarm) \node[#6] at ($(#1)+(#8)$) {#5}; } \begin{document} \begin{tikzpicture}[grow'=right] \tikzset{level distance=2cm} \tikzset{sibling distance=1cm} \tikzset{every tree node/.style={anchor=base west}} \Tree[.\node (a) {a}; [.\node (b) {b}; [.\node (d) {d}; ] [.\node (e) {e}; ] [.\node (e2) {e$_2$}; ] [.\node (e3) {e$_3$}; ] ] [.\node (c) {c}; [.\node (f) {f}; ] [.\node (g) {g}; ] [.\node (h) {h}; ] ] ] \sparc{a}{b}{c}{0.7}{OR}{red}{ultra thick,color=blue!50!cyan}{1.5,0} \sparc{b}{d}{e3}{0.6}{AND}{yellow,circle,fill=green!50!gray}{ultra thick,color=red!50!orange}{1,0} \sparc{c}{f}{h}{0.6}{OR}{blue,circle,fill=blue!50!gray,fill opacity=0.3,text opacity=1}{ultra thick,color=green!30!gray}{1,0} \end{tikzpicture} \end{document} 

enter image description here

Source Link
Tom Bombadil
  • 40.7k
  • 10
  • 137
  • 193
Loading