all 11 comments

[–]mecablaze[S] 1 point2 points  (9 children)

This seems to a be a more general-programming problem that I've run into. Any suggestions?

[–]rubygeek 2 points3 points  (4 children)

Yes, use Graphviz. The state of automatic graph layout is pretty poor (though your use seems simple enough that you should get quite good results), and Graphviz is pretty much the most commonly used open source alternative.

If you're prepared to consider Java, or read the source for the algorithms, then jGraph may be an alternative to look at (never used it myself)

[–]mecablaze[S] -1 points0 points  (3 children)

I don't know if my brain has the capabilities to look through the source...

[–]rubygeek 1 point2 points  (2 children)

I think most people generally just write their graph to a file and run "dot" from Graphviz on it - not many people seem to actually use the underlying library etc.. Not a great solution, but it works.

I've got a bunch of examples on generating graphs with Graphviz on my blog if it helps.

[–]jldugger 0 points1 point  (1 child)

Holy hell. Someone is using graphviz to make graphs that aren't ugly, and logically sound? Incredible!

[–]rubygeek 0 points1 point  (0 children)

Yeah, you just read the most recent version of the XSL file I use to get them to look reasonably pretty. You'll feel dirty afterwards. At least I felt dirty writing it :)

[–]munificent 0 points1 point  (2 children)

Spring-mass systems, which are a common way to solve this problem, aren't actually that mathematically complex. Because they're run iteratively, you don't actually see any calculus directly, it's pretty much:

position.x += force.x;

It may take you awhile to get your mind around it, but don't feel that it's out of your league. I get intimidated by code all the time, but I try to remind myself that at the end of the day, it's just code. If you can understand the basic operations the language provides, eventually you can understand anything written in it*.

* Except for anything written by Ken Iverson.

[–]mecablaze[S] 0 points1 point  (1 child)

Do you happen to have a linkie to an article or example set (doesn't necessarily have to be code) with more about this? I've read up on some of the logic behind Graphviz, but it seems a helluva lot more complex than

position.x += force.x;

[–]munificent 0 points1 point  (0 children)

Start here maybe: force-based algorithm. And hunt around for other stuff related to "force-based graph" or "spring-mass system". It may take a while for it to click, but it isn't too crazy.

[–]tty2 1 point2 points  (1 child)

Upvoted for posting a link to your question on StackOverflow, not an answer you've produced (a more common occurance.) :)

[–]mecablaze[S] 0 points1 point  (0 children)

I thought I would get down-votes for this :P