Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|cite|improve this question

If the graph is acyclic, you can use topological sorting to assign a vertical level to every vertex.

share|cite|improve this answer
Could you please give a working example? Thank you. – Qiang Li May 7 '12 at 18:44
@QiangLi: There are two algorithms in the Wikipedia article, and tons of hits if you google topological sorting -- I don't think it's an efficient use of my time to work out another example here. If you have trouble following the descriptions, please ask a specific question about what you don't understand. – joriki May 7 '12 at 18:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.