كيف يمكنني بشكل صحيح عرض بلدي شجرة AVL في اللثي؟ A منفردا توقف ترك الطفل أسفل على التوالي

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