Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:54:25+00:00 2026-05-24T16:54:25+00:00

Does somebody know how do I plot a multiway-tree in a aesthetically plausible way?

  • 0

Does somebody know how do I plot a multiway-tree in a aesthetically plausible way?
info:

  • more or less 100 items
  • each level have approximately the same number of items
  • 10 levels
  • each node have between 0(leaf) and 6 childs
  • each node specify it’s own level, no matter his roots.

I’m currently using PIL, dividing each “line” in img.size()[0]/number of nodes, and drawing lines with draw.line to represent edges, but it is completely messed up

I hope you can help me =], any information needed I’ll post.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:54:27+00:00Added an answer on May 24, 2026 at 4:54 pm

    So, rendering graphs is the particular genius of graphviz, which also happens to have several libraries that provide python bindings. In my opinion, the best of these bindings libraries is pygraphviz. Graphviz is probably the best solution and also likely the simplest.

    The particular layout you describe in your Question, a hierarchical, layered scheme, is performed effortlessly by graphviz’ dot layout engine. Dot performs the rendering to ensure that the graph is laid out in a natural tree configuration–i.e., parent nodes are positioned above their children; nodes of equal rank (levels from the root) are equi-positioned w/r/t the y-axis when possible, and natural symmetry is preserved when possible.

    (Note: confusingly, dot refers to one of several layout engines that comprise graphviz, but dot is also the name and file extension of the file format for all graphviz documents regardless of how they are rendered).

    As you can see in my code that follows, using pygraphviz, it’s simple to select dot as layout engine for your graph, though it’s not actually the default (neato is).

    Here’s a quick graph i made and then rendered using dot–created and rendered using graphviz via pygraphviz.

    Notice that the graph has perfect layout–nodes of the same degree are on the same level along a vertical axis, children are rendered below parents and natural ‘symmetry’ is preserved when possible (e.g., a parent node is positioned between and above its two child nodes. And as you can see, none of my code manually controls the layout–graphviz, i.e., dot, handles it automatically.

    import pygraphviz as PG
    
    A = PG.AGraph(directed=True, strict=True)
    
    A.add_edge("7th Edition", "32V")
    A.add_edge("7th Edition", "Xenix")
    # etc., etc.
    
    # save the graph in dot format
    A.write('ademo.dot')
    
    # pygraphviz renders graphs in neato by default, 
    # so you need to specify dot as the layout engine
    A.layout(prog='dot')
    
    
    # opening the dot file in a text editor shows the graph's syntax:
    digraph unix {
      size="7,5";
      node [color=goldenrod2, style=filled];
      "7th Edition" -> "32V";
      "7th Edition" -> "V7M";
      "7th Edition" -> "Xenix";
      "7th Edition" -> "UniPlus+";
      "V7M" -> "Ultrix-11";
      "8th Edition" -> "9th Edition";
      "1 BSD" -> "2 BSD";
      "2 BSD" -> "2.8 BSD";
      "2.8 BSD" -> "Ultrix-11";
      "2.8 BSD" -> "2.9 BSD";
      "32V" -> "3 BSD";
      "3 BSD" -> "4 BSD";
      "4 BSD" -> "4.1 BSD";
      "4.1 BSD" -> "4.2 BSD";
      "4.1 BSD" -> "2.8 BSD";
      "4.1 BSD" -> "8th Edition";
      "4.2 BSD" -> "4.3 BSD";
      "4.2 BSD" -> "Ultrix-32";
    }
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does somebody know if there is any way to reproduce an ajax suggestion box
Does somebody know how to recover a never-starting eclipse when the error org.eclipse.swt.SWTError: Item
Does somebody know a Java library which serializes a Java object hierarchy into Java
does somebody know how can I embedd an exe file into a dll ?
Does somebody know how modular is Django? Can I use just the ORM part,
Does somebody know why the output of this code is only : Message Sended
Does somebody know, how to call a lightbox from an custom link? Example: $('#price1
Does somebody know a quick and easy explode() like function that can ignore splitter
Under Hudson, does somebody know how to specify a release tag name in a
Does somebody know a rich text editor (like NSTextView for Mac OS X) library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.