This example shows a D3 implementation of the Key Players algorithm, as laid out in Borghatti 2006. We focus on KP-Pos - finding a set of size k that is maximally connected to the other nodes in the graph. We use the greedy optimization algorithm outlined in the paper, and equation (14) as our metric.
Usage: Set a number of key players to find and press "Go!". This will generate a random starting set of size k and then run the optimization algorithm. Alternatively, click nodes to select them, allowing you to view their fit with the KP metric. Then, click the list of selected nodes to run Key Player with your selected nodes as the starting set. Compare sets in the "Found KP-sets" list by hovering over the grey links.
The force-layout was adapted from Mike Bostock's force-directed graph example. As in that example, the data is 'based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.' It looks like this graph has unique local minima that the optimization algorithm finds every time. This is actually a little disappointing, at least for demonstration purposes: the algorithm starts with a random guess, and iteratively improves it. We'd like to be able to see and compare different subsets gotten from different starting guesses, but our Les Misérables characters are too well-behaved!
'keyplayer.js' contains the Key Player implementation. It relies on 'matrix.js', a extremely tiny, in-development JS library I wrote for this example, to allow some higher-level slicing and indexing than provided by Javascript arrays. In my informal, qualitative assessment, it was faster than math.js or Sylvester (my script did not finish executing when I used those libraries). But my library has pretty much NO features besides matrix creation, indexing, and slicing.