tags:

views:

342

answers:

3

Hi there,

That's a simple question: is there an API to draw a B-tree in Java? I just dont want to spend much time reinventing the wheel. I am not having trouble with the algorithm per si, mine works perfectly fine after a lot of reading (specially Lafore's Data Structures & Algorithms in Java), I just dont know how to print a B-tree in a good way.

Thanks in advance.

+3  A: 

You've got a couple of options to "render" a graph to screen -

  • Graphviz has a Java API (Edit: an addon called LJV which gives the API).

  • I think you ought to be able to use the free version of JGraph to do the same.

viksit
A: 

I know people have had success with daVinci (now uDraw). I haven't used it since 2003, but from what I remember, you have to generate a bracketed text file for your tree and the program parses it. You should be able to output your text by doing a simple tree traversal.

Dana the Sane
A: 

Have a look at yEd. I'm pretty sure, licensing yFiles just for an API to display tree structures is a bit exaggerated, but the graph editor is free of license costs and you can use it to render your trees. I usually dump my raw graph data in one of the supported file formats, open the output file with yEd and let it do the layout.

Andreas_D