# A Force-Directed Graph Drawing Algorithm

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:

1. Make all edges as close to the same length as possible.
2. Make all nodes as far apart from each other as possible.

# Three Forces

To accomplish these goals, we established three forces:

1. An attractive force between connected nodes.
2. A repulsive force between unconnected nodes.
3. A damping force to prevent the nodes from moving forever.

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 nv. However, we also wanted connected nodes to be equally spaced. Therefore, we subtracted a unit distance to the difference calculation, giving F=(nv)(1−1/||nv||). 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=−(nv)/||nv||3

Finally, there is a damping force that follows spring damping. The damping force is proportional to the negated velocity of a node.

# Future Work

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.