Graph Example 7 for How to Create Effective Network Data Visualization
One method that seems intuitive for creating links between existing nodes is to allow the user to drag that node onto the node to which you want to make the connection.
This is particularly easy to do when the nodes are circular, since you just have to measure the distance from the center of each node to the center of other nodes. With squares or more irregular shapes, you'll need to settle for less accurate detection or using a bounding-box method.
After making new connections, the modularity is recalculated based on the new links.
The method used here, which creates a background circle that lights up when in the proximity of another node, was first developed by Scott Murray and I for Kindred Britain.
This example relies on the jLouvain library to calculate community structure.
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js