Documentation
¶
Overview ¶
Package cluster runs community detection (Louvain, via gonum) on the graph, then post-processes the result the way the Python original does: oversized communities are split, and IDs are assigned by descending size with a lexical tie-break so the same grouping always yields the same IDs across runs.
Index ¶
- func Cluster(g *model.Graph) map[int][]string
- func Cohesion(g *model.Graph, nodes []string) float64
- func NodeCommunity(communities map[int][]string) map[string]int
- func RemapToPrevious(communities map[int][]string, prevNodeCommunity map[string]int) map[int][]string
- func Scores(g *model.Graph, communities map[int][]string) map[int]float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NodeCommunity ¶
NodeCommunity inverts communities into node ID -> community ID.
func RemapToPrevious ¶ added in v0.6.0
func RemapToPrevious(communities map[int][]string, prevNodeCommunity map[string]int) map[int][]string
RemapToPrevious relabels communities so their integer IDs stay stable across incremental rebuilds. It greedily matches each new community to the previous assignment that overlaps it most (one-to-one, by intersection size with an (oldID, newID) tie-break), then assigns fresh IDs to the unmatched communities in deterministic order (size desc, then lexical tie-break, reusing less). This keeps a per-node community diff meaningful when the grouping is unchanged.
Types ¶
This section is empty.