# 如何在简单的二叉树中选择节点所在的哪一侧？(How to pick which side a node is on in a simple binary tree?)

``` 在一个简单的二叉树中，我能够通过添加不可见节点和不可见边来使图形看起来正确，例如：
```digraph
{
vertex_1 [label="A"];
vertex_2 [label="B"];
vertex_2 -> vertex_1 [label="Left"];
}
```
产生：

至：
```digraph
{
vertex_1 [label="A"];
vertex_2 [label="B"];
vertex_0 [style=invis];
vertex_2 -> vertex_1 [label="Left"];
vertex_2 -> vertex_0 [style=invis];
}
```
产生：

但是当我尝试使用4节点图形（它最初是直接向上和向下）时，这就是我得到的：
```digraph
{
vertex_1 [label="A"];
vertex_2 [label="B"];
vertex_3 [label="F"];
vertex_4 [label="G"];
vertex_01 [style=invis];
vertex_02 [style=invis];
vertex_03 [style=invis];
vertex_4 -> vertex_3 [label="Left"];
vertex_3 -> vertex_1 [label="Left"];
vertex_1 -> vertex_02 [style=invis];
vertex_4 -> vertex_03 [style=invis];
vertex_3 -> vertex_01 [style=invis];
vertex_1 -> vertex_2 [label="Right"];
}
```
产生：

显然我希望B在A的右侧。我尝试将不可见边缘语句的顺序和实际边缘从B切换到A，就像哪一个先出现但是没有区别。 如何告诉程序将特定节点或边缘放在特定端？ In a simple binary tree, I was able to make the graph look right by adding invisible nodes and invisible edges, for instance from:
```digraph
{
vertex_1 [label="A"];
vertex_2 [label="B"];
vertex_2 -> vertex_1 [label="Left"];
}
```
which produces:

to:
```digraph
{
vertex_1 [label="A"];
vertex_2 [label="B"];
vertex_0 [style=invis];
vertex_2 -> vertex_1 [label="Left"];
vertex_2 -> vertex_0 [style=invis];
}
```
which produces:

But when I tried that trick with a 4 node graph (it was originally straight up and down) here is what I got:
```digraph
{
vertex_1 [label="A"];
vertex_2 [label="B"];
vertex_3 [label="F"];
vertex_4 [label="G"];
vertex_01 [style=invis];
vertex_02 [style=invis];
vertex_03 [style=invis];
vertex_4 -> vertex_3 [label="Left"];
vertex_3 -> vertex_1 [label="Left"];
vertex_1 -> vertex_02 [style=invis];
vertex_4 -> vertex_03 [style=invis];
vertex_3 -> vertex_01 [style=invis];
vertex_1 -> vertex_2 [label="Right"];
}
```
which produced:

Obviously I want B to be on the right side of A. I tried switching the order of the invisible edge statement and the actual edge from B to A, like which one came first but that make no difference. How can I tell the program to put a specific node or edge on a specific side?原文：https://stackoverflow.com/questions/36785513```

## 最满意答案

``` 对于从左到右的顺序，节点创建顺序是相关的。 必须在其右兄弟之前创建左节点。
```digraph
{
vertex_1 [label="A"];
vertex_02 [style=invis];
vertex_2 [label="B"];
vertex_3 [label="F"];
vertex_4 [label="G"];
vertex_01 [style=invis];
vertex_03 [style=invis];
vertex_4 -> vertex_3 [label="Left"];
vertex_3 -> vertex_1 [label="Left"];
vertex_1 -> vertex_02 [style=invis];
vertex_4 -> vertex_03 [style=invis];
vertex_3 -> vertex_01 [style=invis];
vertex_1 -> vertex_2 [label="Right"];
}
```
For the order left to right the node creation order is relevant. A left node must be created before its right sibling.
```digraph
{
vertex_1 [label="A"];
vertex_02 [style=invis];
vertex_2 [label="B"];
vertex_3 [label="F"];
vertex_4 [label="G"];
vertex_01 [style=invis];
vertex_03 [style=invis];
vertex_4 -> vertex_3 [label="Left"];
vertex_3 -> vertex_1 [label="Left"];
vertex_1 -> vertex_02 [style=invis];
vertex_4 -> vertex_03 [style=invis];
vertex_3 -> vertex_01 [style=invis];
vertex_1 -> vertex_2 [label="Right"];
}
```
```
2016-04-22

## HTML和CSS间距问题(HTML and CSS spacing issues)

p标签有一个默认的顶部边距（1em？） 尝试重置或使用重置样式表 p { margin-top : 0 } The p tag has a default top margin (of 1em?) try resetting this or use a reset stylesheet p { margin-top : 0 }