1

I have a graph of several thousand nodes and edges and I notice that the performance of Cytoscape.js with force-directed JavaScript layout algorithms (cose and cola) is lacking.

I wonder if I should invest time to look for other libraries or algorithms or if the complexity of those algorithms is too high in general. In a naive algorithm, I guess that every node has to be compared to every other one, so there should be a quadratic complexity, but with clever filtering on data with low connectivity I could imagine good approximations (I don't need mathematically perfect results, just something intuitive for the users).

My goal is to layout a graph in under 10 seconds on a typical user machine.

Publications I found (Google Scholar for "force directed complexity"):

Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118

1 Answers1

1

For the layout algorithm that uses attractive forces between adjacent nodes and repulsive forces between all nodes, you could use a Barnes--Hut style approximation for the repulsive forces that result from faraway nodes. Only a brief sketch here because B--H is a common school assignment, and there should be plenty of tutorial materials on it. The basic idea is, at each step, perform a recursive quad-tree dissection of the input nodes, counting the number of nodes in each subdivision. Then, to approximate the force on a particular node, traverse the tree recursively. If we arrive at a subdivision that is far from that node, then calculate the repulsive force as if every node in the subdivision lies at the center (or precompute the mean, whatever seems to work).

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120