Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What algorithms does D3.js use for the force-directed graph?

I would be interested to know exactly what algorithms D3 uses to achieve the force-directed graph feature in the library. Having read Kobourov's summary of the history of force-directed graphs left me a bit baffled as to what is the exact algorithm or method (combination of algorithms / heuristics) used in the library.

D3 API reference says Barnes-Hut algorithm is used to calculate the charges acting on bodies, an O(N*log(N)) operation. Kobourov's article mentions that Quigley-Eades algorithm, and Hu's algorithm are multilevel algorithms that make use of Barnes-Hut. Is one of them utilized in some way in D3?

The API wiki futher says Verlet integration is used for particle positioning. The source code mentions Gauss-Seidel algorithm, which in turn is mentioned both in Hu's algorithm and Dwyer's graph layout paper. I guess the question I'm looking an answer to is what "integrative" algorithm D3 utilizes; Kobourov's article lists several and D3 force-directed features don't directly seem to fit any of those.

like image 292
amergin Avatar asked Oct 16 '12 14:10

amergin


2 Answers

In the original d3 paper, Mike Bostock & al. wrote that Dwyer's implementation is used for the force graph layout :

The force layout combines physical simulation and iterative constraint relaxation [7] for stable graph layout.

[7] T. Dwyer. Scalable, versatile and simple constrained graph layout. In EuroVis, 2009.

For more information, Dwyer's paper describes in details the whole algorithm.

like image 172
Clément Renaud Avatar answered Nov 11 '22 16:11

Clément Renaud


Well, this isn't an answer to your specific question, but on his demo page for force-directed layout, he says, "Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen."

like image 42
Pat Avatar answered Nov 11 '22 16:11

Pat