xander
xander

Reputation: 1447

Easiest way to draw tree diagrams?

I want to have a program which generates diagrams for trees, ones looking pretty much like this

It is to be a part of a project I am working on using C#, but if there is a way to make a Python or Javascript do it, that be okay as well. Maybe some C# library, or JavaScript/Python library with parameters I can provide to it ?

The most important thing, regardless of the programming language, is that it be easy to use.

Upvotes: 2

Views: 3723

Answers (2)

user2398029
user2398029

Reputation: 6937

You may want to use pydot, which is an interface to the Graphviz .DOT format visualization software. As outlined in the Graphviz guide, the .DOT format lets you design graphs similar to the one you posted as well as more much more sophisticated ones.

Here's an example from the pydot doc:

import pydot
graph = pydot.Dot('graphname', graph_type='digraph') 
subg = pydot.Subgraph('', rank='same') 
subg.add_node(pydot.Node('a')) 
graph.add_subgraph(subg) 
subg.add_node(pydot.Node('b')) 
subg.add_node(pydot.Node('c'))

If you're looking at Javascript instead, canviz is a well-respected library that allows you to draw .DOT graphs to browser canvases.

Upvotes: 3

Tom Savage
Tom Savage

Reputation: 3182

There is a C# wrapper around the Graphviz bindings.

I'm working on a project that generates trees with Graphviz (not in C# though) and it works great.

Upvotes: 1

Related Questions