I have an application in which users interact with each-other. I want to visualize these interactions so that I can determine whether clusters of users exist (within which interactions are more frequent).
I’ve assigned a 2D point to each user (where each coordinate is between 0 and 1). My idea is that two users’ points move closer together when they interact, an ‘attractive force’, and I just repeatedly go through my interaction logs over and over again.
Of course, I need a ‘repulsive force’ that will push users apart too, otherwise they will all just collapse into a single point.
First I tried monitoring the lowest and highest of each of the XY coordinates, and normalizing their positions, but this didn’t work, a few users with a small number of interactions stayed at the edges, and the rest all collapsed into the middle.
Does anyone know what equations I should use to move the points, both for the ‘attractive’ force between users when they interact, and a ‘repulsive’ force to stop them all collapsing into a single point?
Edit: In response to a question, I should point out that I’m dealing with about 1 million users, and about 10 million interactions between users. If anyone can recommend a tool that could do this for me, I’m all ears 🙂
In the past, when I’ve tried this kind of thing, I’ve used a spring model to pull linked nodes together, something like:
dx = -k*(x-l).dxis the change in the position,xis the current position,lis the desired separation, andkis the spring coefficient that you tweak until you get a nice balance between spring strength and stability, it’ll be less than 0.1. Havingl > 0ensures that everything doesn’t end up in the middle.In addition to that, a general ‘repulsive’ force between all nodes will spread them out, something like:
dx = k / x^2. This will be larger the closer two nodes are, tweakkto get a reasonable effect.