As programmers, we often write very complex data structures. The hard part about maintaining complex data structures, is tracing bugs - since let's face it, in many places it's not practical to find which node out of several hundreds is deffected.
That's why I started a new project, called LibStructureGraphic. It's a library in Java, for visualizing data structures while making minimal or even no changes to their code. And since a picture is worth
Visualizations of a Binomial Heap (top) and a Red Black Tree (bottom) Click to view fullsize |
The idea is that having a visualization of the graph should help the programmer see more data at once, and speed up the times spent on finding bugs. I personally used custom code for drawing some data structures (for debugging) during my data structure course, and this was the source of this project. The visualization saved me hours of debugging!
The library requires a data structure to have the following properties in order to be visualized:
- For now (will change in the future), the data structure must be representable as a Tree, which means it's composed of nodes where each node has exactly 1 parent and zero or more children.
Support for Directed-Acyclic-Graphs (DAGs) will be added in one of the next versions, and support for cyclic graphs is planned for the future - Each node of the data structure should be represented by an object, which either implements a given interface (for finding the "children", "value" and "color" of the node), or has annotations on the fields that should be drawn. Ideally, the annotations are the preferred way since they mean you don't need to implement any custom functions; The interface is there only for nodes in which it's not possible.
The nodes don't have to be of the same type - each node can be a completly different type of object!
And, the GIMP connection to this project (you didn't really expect me to write a post without mentioning GIMP, didn't you?) is that I'm working on a node-editor for GEGL. I knew I needed to implement a graph layout algorithm for it, and since I'm prototyping everything in Java, I thought of making a library from it.
כבוד!
ReplyDelete