Patrick (patrickwonders) wrote,

Visualizing Code

Inspired by a recent post by jerronimo, I threw together some code to visualize the interconnections of code.

It's a pretty straightforward representation. Each node is a function (or macro). There is a spring between two nodes if one function calls the other. There is also a repulsive force between functions so that they don't get too close together.

I'd like to make the rest length of a spring shorter between foo() and bar() if foo() calls bar() a bunch of times. But, that's not implemented yet.

I also need to incorporate some way to move your viewpoint a bit because somehow or other, the equillibrium between the repulsive force and the spring tension isn't really where I expect it, so lots of stuff grows right off the edges of the window. Actually, what I really need to do is figure out why my spring system is so unstable. I damped the motion and things got a little better, but things still grow more than I think they should.

I'd also like to add in labelling and/or color coding the vertices.

Anyhow, here are some shots. This first one is a vector-math library that has eleven functions and one macro.

visualization of vec-math library

This next one shows the code that does the analysis and display. On the left is how the code looked yesterday. On the right is how the code looks now.

visualization of vis code

All of the related code is now hosted on GitHub. Here is the code base. It requires that the following libraries be available somewhere that ASDF can find them:

Tags: code, lisp

  • Let's Talk About Coin Flips

    There has been lots of talk in the last 24 hours about coin flips. If a precinct had, for example, five delegates to award and the caucus-goers…

  • Applicable Proofs...

    We both know it's been forever since I posted on LJ. This one's too long for Twitter and doesn't mesh well with my mostly-Lisp blog. 'Nuff said.…

  • Null Intersection Hypothesis?

    Here's the situation. You're in an all-day meeting at work. It comes time to order the pizza for lunch. A quick survey of the 20 people present…

  • Post a new comment


    default userpic

    Your reply will be screened

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.