visualize c++ data structure

2k Views Asked by At

I am looking for a program to help me debug a tree in c++. My tree has thousands of nodes and I want to view the tree as it forms and view problem nodes and branches. Operating system doesn't matter. Anyone know of a program that can do this?

4

There are 4 best solutions below

1
On

Don't know what platform you are at, but DDD is pretty good with this, though can't say anything about its performance on huge sets.

0
On

Have you considered Dot?

0
On

The only practical way I know is to write your own ! A good design solution is to implement a visitor design pattern. Then you can have different visitor like :

  • a print visitor, that print your tree in the console (not practical as you say you have a lot of nodes)
  • a serialize visitor : It will write your tree in a file.

You can then "debug" by calling the appropriate visitor at key points.

my2c

0
On

I have written a library called DSViz which is used to do this job. You can find it here: https://github.com/sunxfancy/DSViz

You need to write a few lines of code to use the API to generate a graphviz file so that you can draw the figure using addition tools.