Documentation
¶
Overview ¶
Package community provides pluggable graph community detection algorithms.
Each algorithm implements the Algorithm interface. The registry maps string names to implementations so callers can select by name (CLI flag, MCP param, export option).
To add a new algorithm:
- Create a file (e.g. leiden.go) implementing Algorithm
- Register it in init() or Registry
Index ¶
Constants ¶
const Default = "louvain"
Default is the algorithm used when none is specified.
Variables ¶
var Registry = map[string]Algorithm{ "louvain": &Louvain{Resolution: 1.0, MaxPasses: 20}, "louvain-fine": &Louvain{Resolution: 0.3, MaxPasses: 20}, "label-propagation": &LabelPropagation{MaxIterations: 50}, }
Registry maps algorithm names to implementations.
Functions ¶
Types ¶
type Algorithm ¶
Algorithm detects communities in a graph. Returns a map from node hash to community ID (int). Community IDs should be contiguous starting from 0.
type Graph ¶
type Graph struct {
Nodes []types.Hash
Adj map[types.Hash][]WeightedEdge
NodeSet map[types.Hash]bool
EdgeCount int
}
Graph holds the adjacency list and node set for community detection.
type LabelPropagation ¶
type LabelPropagation struct {
MaxIterations int
}
LabelPropagation implements the label propagation community detection algorithm. Each node adopts the most common label among its neighbors. Fast and simple but non-deterministic (results vary between runs).
func (*LabelPropagation) Name ¶
func (lp *LabelPropagation) Name() string
type Louvain ¶
Louvain implements single-pass Louvain modularity optimization. Resolution controls granularity: lower values produce fewer, larger communities.
type WeightedEdge ¶
WeightedEdge represents a graph edge with a weight (typically confidence).