在 LaTeX 中按层次结构连接相邻节点?

在 LaTeX 中按层次结构连接相邻节点?

所以,我对在 Latex 中创建层次结构图还很陌生。基本上,我想要做的是连接相邻节点。下面是层次结构图的一个小示例...

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows.blur}

\begin{document}
    \begin{forest}
for tree={
    draw, semithick, fill=white, blur shadow,
    align=left,
%
    grow'=0,
    anchor = west,
    forked edges,                  
     edge = {-stealth},
    l sep = 2.5em,
 fork sep = 1.2em,
tier/.option = level,
        }
[VImp Methods
 [Model Agnostic
    [Filter Methods
        [Chi-Squared]
        [t-statistic]
        [ANOVA]
    ]
  ]
 [Wrapper Methods
     [Recursive Feature elimination]
     [Backward Elimination]
 ]  
 [Model Based
    [Embedded Methods
        [Random Forest
            [Gini]
            [Permutation]
        ]
    ]
   ]
]
\node [draw, inner sep=1ex,
       fit=(current bounding box.south east) 
           (current bounding box.north west)] {};
\end{forest}
\end{document} 

结果是: 等级制度

但我想要实现的是这样的:

层次结构 2

在上面的例子中,我希望能够加入模型无关基于模型...然后让他们都加入包装器方法

关于我该如何做这件事,有什么建议吗?

答案1

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows.blur}

\begin{document}
    \begin{forest}
for tree={
    draw, semithick, fill=white, blur shadow,
    align=left,
%
    grow'=0,
    anchor = west,
    forked edges,                  
     edge = {-stealth},
    l sep = 2.5em,
 fork sep = 1.2em,
tier/.option = level,
        }
[VImp Methods
 [Model Agnostic,alias=agnostic
    [Filter Methods
        [Chi-Squared]
        [t-statistic]
        [ANOVA]
    ]
  ]
 [,phantom,no edge
   [Wrapper Methods,alias=wrap
     [Recursive Feature elimination]
     [Backward Elimination]
     ]
 ]  
 [Model Based,alias=model
    [Embedded Methods
        [Random Forest
            [Gini]
            [Permutation]
        ]
    ]
   ]
]
\draw[-stealth] (agnostic.south) -- (agnostic|-model.north)
  (wrap-|agnostic) -- (wrap.west) ;
\node [draw, inner sep=1ex,
       fit=(current bounding box.south east) 
           (current bounding box.north west)] {};
\end{forest}
\end{document} 

在此处输入图片描述

相关内容