UNPKG

ngraph.louvain

Version:

Given a graph instance detects communities using the Louvain Method

26 lines (22 loc) 468 B
var colors = [ '#1f77b4', '#aec7e8', '#ff7f0e', '#ffbb78', '#2ca02c', '#98df8a', '#d62728', '#ff9896', '#9467bd', '#c5b0d5', '#8c564b', '#c49c94', '#e377c2', '#f7b6d2', '#7f7f7f', '#c7c7c7', '#bcbd22' ]; var lastUsed = 0; var idToIndex = Object.create(null); function getColor(id) { var idx = idToIndex[id]; if (idx === undefined) { idx = idToIndex[id] = lastUsed; lastUsed += 1; } return colors[idx]; } module.exports = getColor;