Visualizing graphs with force-directed layouts
One popular way to visualize graphs of data is to use a force-directed layout. This employs a physical simulation of charged particles and springs to create an aesthetically pleasing visualization. It minimizes crossed lines while keeping all the edges more or less of the same length. This makes the relationships in the graph immediately clear, at the expense of expressing the distances between nodes. For example, consider the following diagram. On the left, we have a graph that is randomly laid out. On the right, it's laid out using a force-directed layout. Each of the edges is approximately as long as the others, and each node is as far away from its neighbors as it can get:
In this recipe, we'll create a force-directed graph visualization for a K-Means cluster of the US census race data aggregated by state.
Getting ready
We'll use the same dependencies and plugins in our project.clj
file as we did in the Creating scatter plots...