
내 코드는 다음 그래프를 생성합니다.
\documentclass{standalone}
\usepackage{tikz}
\usepackage{dot2texi}
\begin{document}
\begin{tikzpicture}[auto]
\tikzstyle{n} = [draw,shape=rectangle,minimum size=2em,inner sep=2pt,align=center, font=\sffamily]
\begin{dot2tex}[dot,tikz,codeonly,styleonly, options= -s ]
digraph G {
overlap = false;
node [style="n"];
root
top1
top2
subgraph cluster_top3 {
top3 ;
color=invis;
top3 -> {311 312} -> 32 -> {331 332 333} -> 34 -> 35 -> 36;
}
subgraph cluster_top4 {
color=invis;
top4 -> 41 -> {421 422} -> 43 -> 44 -> 45;
}
root -> {top1 top2 top3 top4};
}
\end{dot2tex}
\end{tikzpicture}
\end{document}
보이지 않는 노드/가장자리를 조작하지 않고 대칭 하위 그래프를 생성하는 방법이 있습니까? 나는 삼각형을 원 311 -- top3 -- 312
하고 421 -- 41 -- 422
정사각형 각도를 갖기를 원합니다.
답변1
pgf 매뉴얼을 파헤친 후 나는 이 솔루션을 생각해 냈습니다. 그러나 하위 트리의 수준은 잘못 정렬되었습니다.
\RequirePackage{luatex85}
\documentclass\[tikz,12pt,border=0pt\]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\usegdlibrary{layered}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}\[>=stealth, -, line width=2pt, every node/.style={circle, font=\Large, draw=black, minimum size=1.45cm, fill=white, anchor=center, align=center, line width=2pt}\]
\graph \[tree layout, level distance=2cm, sibling distance=2cm, components go up center aligned=true\]
{
"top" -- {1, 2, 3, 4};
// \[layered layout, level distance=2cm, sibling distance=2cm\]{{311, 312} -- 32 -- {331, 332, 333} -- 34};
3 -- {311, 312};
// \[layered layout, level distance=2cm, sibling distance=2cm\] {41 -- {421, 422} -- 43;};
4 -- 41;
};
\end{tikzpicture}
\end{document}