Force-directed graph drawing algorithms treat the nodes of a graph as point masses. A force is applied to each node such that the force causes the node positions to favor a certain goal. Then mechanics calculations are applied to the nodes so that a local minimum is reached with respect to the goal.
In this algorithm implementation, we favored two goals:
To accomplish these goals, we established three forces:
An attractive force between connected nodes is fairly simple. It could simple be that a node v exerts a force on a neighbor F=n equal to n−v. However, we also wanted connected nodes to be equally spaced. Therefore, we subtracted a unit distance to the difference calculation, giving F=(n−v)(1−1/||n−v||). This has the effect of causing connected nodes to attract or repulse each other until they are a unit distance away from each other.
For the repulsive force we used Coulomb repulsion. The repulsive force is proportional to the square of the distance between two nodes. Therefore, given two nodes, the repulsive force is equal to F=−(n−v)/||n−v||3Finally, there is a damping force that follows spring damping. The damping force is proportional to the negated velocity of a node.
For future versions, we want to implement an interface that allows the user to add and remove points and edges. Removing edges would cause an edge contraction. After that is added, it would help to have a way to save and load graphs.
We also want to try different algorithms and goals, including ones that are not force-directed, including Tutte's algorithm. We want to do 2-dimensional embeddings and projections from 3-dimensional embeddings to 2-dimensional embeddings.