0

What is the simplest way to obtain the following tree like graph ?

enter image description here

projetmbc
  • 13,315

4 Answers4

7

The TikZ graphs library can do this quite simply:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}
\graph[branch right, grow down] 
{a[x=1] <- {{b <- {d[x=-1],e}}, {c <- {e,f[x=1]}}}};
\end{tikzpicture}
\end{document}

output of code

If you want the graph to be more compact, like your image, you can reduce the branch width. Since the node adjustments depend on that width too, it's best to use a macro like this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs}
\newcommand*{\bw}{.5}
\begin{document}
\begin{tikzpicture}
\graph[branch right=\bw, grow down] 
{a[x=\bw] <- {{b <- {d[x=-\bw],e}}, {c <- {e,f[x=\bw]}}}};
\end{tikzpicture}
\end{document}

output of second code

Alan Munn
  • 218,180
5

Easy and simple too with a psmatrix environment:

\documentclass{article}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} %% to compile with pdflatex --enable-write18 (MiKTeX) or pdflatex --shell-escape (TeX Live, MacTeX))

\begin{document}%

\begin{psmatrix}[rowsep=1cm, colsep=0.9cm]
& &[name=a] a \\
& [name=b] b & & [name=c] c \\
[name=d] d & & [name=e] e & & [name=f] f
\foreach \beg/\targ in {b/a, c/a, d/b, e/b, e/c, f/c}{\ncline[arrows=->, arrowinset=0.12, nodesep=3pt]{\beg}{\targ}}
\end{psmatrix}

\end{document} 

enter image description here

Bernard
  • 271,350
4

Another alternative since the graph is very simple using tikz-cd.

enter image description here

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\begin{document}
\begin{tikzcd}
 &  & a &  &  \\
 & b \arrow[ru] &  & c \arrow[lu] &  \\
d \arrow[ru] &  & e \arrow[lu] \arrow[ru] &  & f \arrow[lu]
\end{tikzcd}
\end{document}

For the your question you can see this link to modificate the type of the arrows: Is it possible to change the size of an arrowhead in TikZ/PGF?

Below new example. I have modificated the thick of one arrow. enter image description here

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows}
\usepackage{amsmath}
\begin{document}
\begin{tikzcd}
 &  & a &  &  \\
 & b \arrow[-triangle 90,
        line width=.8mm,ru] &  & c \arrow[lu] &  \\
d \arrow[ru] &  & e \arrow[lu] \arrow[ru] &  & f \arrow[lu]
\end{tikzcd}
\end{document}
Sebastiano
  • 54,118
1

A hurried attempt with MetaPost and its boxes package, included in a LuaLaTeX program.

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
    \mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}
input boxes;
def junction(suffix a, b) =
    drawarrow a.c -- b.c cutbefore bpath.a cutafter bpath.b;
enddef;
h := 1.25cm; v := 1cm;
beginfig(1);
    forsuffixes z = a, b, c, d, e, f: circleit.z(str z); endfor;
    e.c = origin; f.c = (h, 0) = - d.c;  
    b.c = (-.5h, v); c.c = (.5h, v);
    a.c = (0, 2v);
    drawunboxed(a, b, c, d, e, f);
    junction (b, a); junction(c, a);
    junction(d, b); junction(e, b);
    junction(e, c); junction(f, c);
endfig;
\end{mplibcode}
\end{document}

enter image description here

It could certainly have been more proficiently coded if I had used, for example, the metaobj package, but I don't know it well enough.

Franck Pastor
  • 18,756