라텍스에 AVL 트리를 올바르게 표시하려면 어떻게해야합니까? 솔로 왼쪽-자녀가 똑바로 매달려 있습니다

StackOverflow https://stackoverflow.com/questions/2454526

  •  20-09-2019
  •  | 
  •  

문제

아래 코드는 거의 완벽하게 작동하지만 9, 7의 자녀는 좌파 대신 똑바로 매달려 있습니다. 어떻게 수정할 수 있습니까?

\usepackage{tikz}
\usepackage{xytree}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
    \node [circle,draw] {4}
      child {
        node [circle,draw] {2}
            child {node [circle,draw] {1}
       }
        child {
            node [circle,draw]{3}
        }
      }
      child {node [circle,draw] {6}
        child {node [circle,draw]  {5}
        }
      child {node [circle,draw]  {9}
        child {node [circle, draw]  {7}}
      }
    };

\end{tikzpicture}}

감사합니다, CB

도움이 되었습니까?

해결책 2

제안 된대로 Tikz 매뉴얼과 상담 한 후 다음과 같이 이것을 수정할 수있었습니다.

\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
    \node [circle,draw] {4}
      child {
        node [circle,draw] {2}
            child {node [circle,draw] {1}
       }
        child {
            node [circle,draw]{3}
        }
      }
      child {node [circle,draw] {6}
        child {node [circle,draw]  {5}
        }
      child {node [circle,draw]  {9}
        child {node [circle, draw]  {7}} 
        child [missing]
        }
    };

    \end{tikzpicture}

다른 팁

아래 코드는 저를 위해 작동합니다. 그것은 당신의 코드를 기반으로하며, 변경 사항과 함께

1) Tikz 라이브러리 트리 사용 및 2) 단일 노드의 서식 변경 (노드 7)

자세한 내용은 Tikz 매뉴얼을 참조하십시오

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}

\begin{document}

\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
    \node [circle,draw] {4}
      child {
        node [circle,draw] {2}
            child {node [circle,draw] {1}
       }
        child {
            node [circle,draw]{3}
        }
      }
      child {node [circle,draw] {6}
        child {node [circle,draw]  {5}
        }
      child {node [circle,draw]  {9}
        child[grow via three points={one child at (-1,-1) and two children at (-.5,1) and (.5,1)}] {node [circle, draw]  {7}}
      }
    };

\end{tikzpicture}

\end{document}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top