There are many tools and SDKs which layout a graph. ogdf, GraphViz, mxGraph, yEd…

One of useful layouts is “Hierarchical Layout”. But there is no pure algorithm or pseudo code to describe it. Even, There is not a clear definition of this type of layout. Is anyone know about the algorithm?
(source: yworks.com)
Simple hierarchical layout algorithm is visualisation of the ASAP sheduling algorithm (check this lecture [link]), so it’d be better to read it, on my view.
BTW your picture is not fully correct – the proposed visualisation is only one of the possible ones.
Imagine, that you have list of node and you know dependence between them.
Node list
Dependency list
would be your layer#1 nodes. Draw them.
And the same thing for the layer#2 and etc.
Finally, you’ll get:
This will work only for non-cyclic directed graphs. For the undirected ones you should modify the algorithm a bit (take random node as root), but the main idea, I think, is understandable.