# How to draw a directed graph with arrows showing vertically from bottom to top

If I have a directed graph, how can I draw it with arrows pointing vertically from bottom to top, like showing a class inheritance pattern in OOP(object oriented programming)?

-
Does LayeredGraphPlot do what you want? –  celtschk May 7 '12 at 21:58

Consider the TreePlot function. This page in the documentation should be useful.

One difference between TreePlot and LayeredGraphPlot (as suggested by R.M.) seems to be that TreePlot can handle multiple ''trees'' within the one graph, which might be what you need to trace inheritance in OOP for a large group of functions.

Here is an example lifted directly from the documentation:

TreePlot[Table[i -> Mod[i^3, 221], {i, 0, 221}]]


The other difference between TreePlot and LayeredGraphPlot is that TreePlot will lay out the graph without reference to the direction of the edges, if necessary, but LayeredGraphPlot is specifically for drawing hierarchical directed graphs.

-

You'll need to use LayeredGraphPlot. Taking an example from the documentation:

LayeredGraphPlot[{"Total" -> "TotalDispatch",
"TotalList" -> "CheckThreading", "TotalList" -> "TotalDispatch",
"TotalSparse" -> "TotalDispatch", "TotalSparse" -> "TotalDispatch",
"TotalDispatch" -> "TotalDispatch", "TotalDispatch" -> "TotalList",
"TotalDispatch" -> "TotalPacked", "TotalDispatch" -> "TotalSparse"},
VertexLabeling -> True]


-
As mentioned by others, you could use LayeredGraphPlot for this. However, LayeredGraphPlot orders vertices in such a way that directed edges are generally pointing down. To flip the graph over, you could reverse the edges and supply a custom EdgeRenderingFunction, e.g.
edges = {2 -> 1, 3 -> 1, 4 -> 1, 5 -> 2, 6 -> 1, 7 -> 3, 8 -> 7, 9 -> 8};

@QiangLi Try changing the AspectRatio and ImageSize –  rm -rf May 8 '12 at 0:59