Various optimizations for automatic graph layout

- Output nodes are put on the rightmost layer and are sorted based on
their original vertical coordinates.
- Input nodes are put on the leftmost layer.
- Isolated nodes are also put on the leftmost layer, below the input
nodes.
- Improvement in node positioning implementation.