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

  • Home
  • SEARCH
  • 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 828983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:48:40+00:00 2026-05-15T03:48:40+00:00

I am trying to create a tree structure with graphviz. I am open to

  • 0

I am trying to create a tree structure with graphviz. I am open to either writing the graphviz code by hand or using the ruby-graphviz gem for ruby. Given the below picture can anyone provide any insight on the necessary code? Ignore that the lines are not straight…they should be when graphviz builds the graph. I am open to having dots/points when lines intersect as well.

I have played with ruby-graphviz and the family tree class…this is getting me part of the way there but I really need all lines to be straight and intersect at right angles and the out-of-the-box code doesn’t seem to do that.

The code should be generic enough to allow for the “C” box to have children as well and for there also to be more children under “A”.

The colors are irrelevant…the examples can exclude any coloring.

http://docs.google.com/drawings/pub?id=1lUTfgKP_LN0x7C3ItbsFjfLBuDTL84AtmoaW7YFn32Y&w=1036&h=713

  • 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-15T03:48:40+00:00Added an answer on May 15, 2026 at 3:48 am

    As far as I know this requires a little work-around; I will only do it in Graphviz DOT language. I give you the solution first, then provide some explanations of how you can extend it.

    This is the resulting figure:

    outfile.png

    This is the Graphviz code producing the figure:

    graph atree {
      Item1 [shape=none,label="Item 1",pos="2.2,1.1!"];
      Item2 [shape=none,label="Item 2",pos="2.2,0.1!"];
      Item3 [shape=none,label="Item 3",pos="2.9,-0.3!"];
      A [shape=box,color=lightblue,style=filled,pos="2,3!"];
      B [shape=box,color=lightblue,style=filled,pos="1,2.1!"];
      C [shape=box,color=lightblue,style=filled,pos="3,2.1!"];
      D [shape=box,color=lightblue,style=filled,pos="1.5,1.5!"];
      E [shape=box,color=lightblue,style=filled,pos="1.5,0.5!"];
      D0 [style=invisible,fixedsize=true,width=0,height=0,pos="2,2.5!",label=""];
      D1 [style=invisible,fixedsize=true,width=0,height=0,pos="1,2.5!",label=""];
      D2 [style=invisible,fixedsize=true,width=0,height=0,pos="3,2.5!",label=""];
      D3 [style=invisible,fixedsize=true,width=0,height=0,pos="1,1.5!",label=""];
      D4 [style=invisible,fixedsize=true,width=0,height=0,pos="1,0.5!",label=""];
      D5 [style=invisible,fixedsize=true,width=0,height=0,pos="1.5,1.1!",label=""];
      D6 [style=invisible,fixedsize=true,width=0,height=0,pos="1.5,0.1!",label=""];
      D7 [style=invisible,fixedsize=true,width=0,height=0,pos="2.2,-0.3!",label=""];
      A -- D0 -- D1 -- B -- D3 -- D4 -- E [color=blue];
      E -- D6 -- Item2 -- D7 -- Item3 [color=blue];
      D0 -- D2 -- C [color=blue];
      D3 -- D -- D5 -- Item1 [color=blue];
    }
    

    If you put it in a file named inputfile.dot you can get the resulting image file by using the command neato -Tpng inputfile.dot > outfile.png.

    Now a couple of comments on how it works: The code building the tree with A, B, C, D, E, Item1, Item2, Item3 is straightforward (the attributes merely set the colors and box styles). The trick to get the lines straight and orthogonal consists of 1) adding invisible nodes with zero size to the graph, and 2) positioning all objects in absolute coordinates on the canvas. The auxiliary nodes D1, D2, D3, D4, D5, D6, D7 are needed for step 1) and the pos="x,y!" options are needed for step 2). Note, that you need the ! sign at the end of the pos command since otherwise the positions would not be considered final and the layout would still get changed.

    You can add additional nodes by first positioning a new node (by using the code for the nodes A ... Item3 as a template), adding an invisible, auxiliary node (with pos such that all connections to and from it are orthogonal) and then adding the connection to the graph via <StartingNode> -- <AuxiliaryNode> -- <NewNode>.

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

Sidebar

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.