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 7598559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:26:09+00:00 2026-05-30T22:26:09+00:00

I am working on some programs using trees. I was wondering if there is

  • 0

I am working on some programs using trees. I was wondering if there is any piece of code to draw general trees in OCaml.

type Tree = Node of Tree * int * Tree | Child of int;;

All I find on internet uses Caml Light, not Objective Caml.
Thanks in advance.

  • 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-30T22:26:11+00:00Added an answer on May 30, 2026 at 10:26 pm

    Could you clarify what you mean by “draw”? I assume you’re thinking of a graphical visualization of the tree?

    I have had reasonably good experience with generating graph/tree descriptions in the dot format, used by the tool graphviz. The idea is that your OCaml program generates a textual representation of the graph in this format, then you use external tools to render it (turn it into an image), and possibly display it on the screen.

    Dot works for general graphs. While you may find specialized tools for binary trees that have more features, in my experience it works rather well with all kind of trees and display something that is usually what you’d like. Now the tool is not without its flaws, and I’ve hit bugs (calling dot segfaults) in some cases. Still I think that’s a reasonable choice.

    How to output in dot format concretely: pick any example of already-existing graph, the structure will be quite obvious : it is only a textual format. Then you write your code running over the graph structure, calling Printf with the right stuff for labels, etc., and voila. For example, this example looks good, and here is the source format. I quote the relevant part:

    /* courtesy Ian Darwin and Geoff Collyer, Softquad Inc. */
    digraph unix {
        size="6,6";
        node [color=lightblue2, style=filled];
        "5th Edition" -> "6th Edition";
        "5th Edition" -> "PWB 1.0";
        "6th Edition" -> "LSX";
        "6th Edition" -> "Interdata";
        "Interdata" -> "Unix/TS 3.0";
        "Interdata" -> "PWB 2.0";
        "Interdata" -> "7th Edition";
        "7th Edition" -> "8th Edition";
        "7th Edition" -> "32V";
        "7th Edition" -> "V7M";
        "V7M" -> "Ultrix-11";
        "8th Edition" -> "9th Edition";
        [...]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So im working on making an automated test for some code. There is an
Whilst working on some generally horrible Javascript code this morning, I came across the
I have been working on some legacy C++ code that uses variable length structures
I'm working on some production software, using C# on the .NET framework. I really
I'm working on a tool that will perform some simple transformations on programs (like
I am working on a learning program and using the Code Rush refactoring tool
Good evening, I am working on a program where some application config info is
I'm working on a program where I store some data in an integer and
I am working on a Windows utility program which communicates with some custom hardware
I'm working on a Google App Engine program that will require some basic spell

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.