层次结构图

层次结构图

我正在尝试使用模板来模仿图片上的内容。

在此处输入图片描述

  \documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[level 1/.style={sibling distance=7cm},
level 2/.style={sibling distance=2cm}, 
level 3/.style={sibling distance=2.5cm}, align = flush center]
\tikzset{every node/.append style={draw,rectangle}}

    \node {Recommendation Systems}
        [style=edge from parent fork down]
        child { 
            node {1}    
            child {node {1.1} 
                child {node {1.1.1} }
                child {node {1.1.2} }
                child {node {1.1.3} }
                }
            child {node {1.2}}
            child {node {1.3}}
        edge from parent node[pos=0.25,above,draw=none]{left}%<-added
        } 
        child { 
            node {2} 
            child {node {2.1}}
            child {node {2.2} 
                child {node {2.2.1} }
                child {node {2.2.2} }
                child {node {2.2.3} }
                }
            child {node {2.3}}
        edge from parent node[pos=0.25,above,draw=none]{right}%<-added
        }
    ;
\end{tikzpicture} 
\end{document}

我不知道如何获得这些盒子。你能帮我/指点一下吗?

答案1

我推荐森林。

\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
for tree={draw,align=center,edge={-latex}}
[Recommendation\\ Systems
 [1.1]
 [1.2
  [1.2.1
   [1.2.1.1]
   [1.2.1.2]
  ]
  [1.2.2
   [1.2.2.1]
   [1.2.2.2]
   [1.2.2.3]
  ]
 ]
 [1.3]
]
\end{forest}
\end{document}

在此处输入图片描述

带阴影:

\documentclass{article}
\usepackage[edges]{forest}
\usetikzlibrary{shadows.blur}
\begin{document}
\begin{forest}
forked edges,
for tree={draw,align=center,edge={-latex},fill=white,blur shadow}
[Recommendation\\ Systems
 [1.1]
 [1.2
  [1.2.1
   [1.2.1.1]
   [1.2.1.2]
  ]
  [1.2.2
   [1.2.2.1]
   [1.2.2.2]
   [1.2.2.3]
  ]
 ]
 [1.3]
]
\end{forest}
\end{document}

在此处输入图片描述

相关内容