cluster

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cluster

func Cluster(g *model.Graph) map[int][]string

Cluster partitions g into communities, returning communityID -> sorted node IDs.

func Cohesion

func Cohesion(g *model.Graph, nodes []string) float64

Cohesion is the ratio of actual intra-community edges to the maximum possible.

func NodeCommunity

func NodeCommunity(communities map[int][]string) map[string]int

NodeCommunity inverts communities into node ID -> community ID.

func Scores

func Scores(g *model.Graph, communities map[int][]string) map[int]float64

Scores returns each community's cohesion score.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL