Link to home
Start Free TrialLog in
Avatar of Jazzle
JazzleFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Tree Drawing in .NET (C#)

Hi,
I need to dynamically draw (graphical) trees to represent simple prefix-notation maths sum, such as "+*xxx" [equal to (x*x)+x ], which would drawn as follows:
'+' at the root, '*' on the root's left branch (with an 'x' as both its leaves), and an 'x' on the root's right branch (a leaf).
(hope that makes sense, though hopefully it doesn't matter if it doesn't)

What I need is a plug-in that can draw these trees given just a string of the sum.
I assume I need free evaluation/demo software for the moment, because I only need to demonstrate the possibilities.
If there's some way of doing this using nothing extra that would be great, but I doubt it.

Any suggestions?  Thanks in advance...
Avatar of malharone
malharone

Is this for display purpose only or for parsing and then computing ?
Look into INORDER trees/graph structures.
Avatar of Jazzle

ASKER

it's for display purposes only, and just one tree at a time.
first given any string .. you'd need to set your order of operation -- eg. operator predescence (i donno if that's the correct spelling)

So given
1+2*3+4/6

you'd have


+  1
    *  2
        3
    /   4
        6


is that right?
Avatar of Jazzle

ASKER

in fact it's easier that than because the string would be in prefix notation:
e.g.  +xy  for x+y  and +*xyz for (x*y)+z

so,  +*xyz  would look like:

    +
   / \
  *   z
 / \
x   y

The real question is, how do I get the system to draw this?
well .. you can't really draw the real trees using the built in controls. you can create a control to owner draw this type of tree. but then you'd have to re-implement the "+" & "-" -- expand and collapse capabilities in addition to formatting .. etc.

so better stick to the Win Explorer format -- using Tree View.
Avatar of Jazzle

ASKER

not really what i was after. and i don't need to expand or collapse branches.

i was hoping there would be a simple way to draw lines and single chars given an input string...
if i get desperate, i might have to do it with ascii!
then you're better off with ASCII ... but even with ASCII you dont have easy way of determining spacing between the elements.
Avatar of Jazzle

ASKER

that's one of the biggies.

i hope someone knows of some software that could do it... (a graphical control of some sort.)
SOLUTION
Avatar of malharone
malharone

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jazzle

ASKER

have had a look at the page, and the applet - although i agree it is very neat, i need more of a solution in C# or a way to create a solution in MS VS2002/3.
There's a product that I had in mind (vaguely) because I remembered some graph layouts that impressed me.  I had to do some searching to find it.

I don't know how much work this would take to use for your application, but it would be sure to create a visually appealing result.  It does do automatic layout, though I don't know how closely that matches your application.  See the diagrams and explanation near the top of the second link.

Tom Sawyer products
http://www.tomsawyer.com/products.html
...
Graph Layout Toolkit  (C++) -- shows good diagrams of their technology
http://www.tomsawyer.com/glt/index.html
...
The Graph Editor Toolkit for the Microsoft Development Community (.NET)
http://www.tomsawyer.com/get/get-windows.html

Cool, huh?


--- --- ---
Other tools I found during my search.  These are not very on-target, but might still be useful.

MetaDraw
http://www.bennet-tec.com/btproducts/metadraw/metadraw.htm

AddFlow
http://www.lassalle.com/afnet.htm

RFFlow
http://www.rff.com/

Process Chart
http://www.processchart.com/

FlowChartX
http://mindfusion.org/download.html
http://mindfusion.org/gallery6.html
Avatar of Jazzle

ASKER

from a quick look at these, some may prove useful.  i will get back to you all when i've had a better look at them.
thanks, and don't hesitate to suggest others. (the software must draw the tree for me, with very simple text input.)
(By the way, don't waste a lot of time on those "not on-target" links.  If they don't look right, just move on.)

Here's a couple more on-target that look very promising, though.

daVinci Presenter
http://www.b-novative.com/developer/dv30_doc/conc_lay.html
http://www.b-novative.com/developer/dv30_doc/term.html
(You could probably do simple text-processing to convert your input strings to their format.)
http://www.b-novative.com/developer/dv30_doc/term_exam.html
Brochure (with diagrams)
http://download.b-novative.com/daVinci_Presenter_Handout_Englisch.pdf

Graphlet, Graphscript
http://www.infosun.fmi.uni-passau.de/Graphlet/index.html

---
Great list of graph drawing tools (Some I've found, some new.)
http://i11www.informatik.uni-karlsruhe.de/algo/cosin/tools.html

---
You might find good info at http://graphdrawing.org
book list:
http://graphdrawing.org/literature/content.html

---
Another aside -- this one you'll probably find interesting.
For math notation, not graphs.

MathML .NET Control 1.0
http://www.dnzone.net/ShowDetail.asp?NewsId=185

---

Hmmmm ... getting a bit carried away here!
Ok, one more ...

Graphviz -- open source graph drawing software
http://www.research.att.com/~north/graphviz/

There seems to be a lot more available in Java, Unix, etc. rather than .NET.

Avatar of Jazzle

ASKER

> There seems to be a lot more available in Java, Unix, etc. rather than .NET.
I do wish I could do it in Java, but have to use C++/C# for the speed. (Genetic Programming is the main task for my system)
Avatar of Jazzle

ASKER

I will be back in a couple of days when I expect to dish out the points!
Avatar of Jazzle

ASKER

anything further anyone?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jazzle

ASKER

thanks to farsight, and to malharone.
points split as appropriate.
Avatar of Jazzle

ASKER

this is long overdue, but I thought I shold say what I did in the end.
I used that last suggestion, Northwoods, with a free educational license.

My diss is at http://www.jazzle.co.uk/GPGUI.pdf (1.74MB PDF )and contains some more info if you're interested.
Thanks for the feedback.