scc

package
v0.3.49 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package scc provides a parallel FW–BW SCC condensation for directed graphs, adapted for Baton’s entitlement graph. It builds an immutable CSR + transpose, runs reachability-based SCC (with parallel BFS and parallel recursion), and returns components as groups of your original node IDs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CondenseFWBWGroupsFromAdj

func CondenseFWBWGroupsFromAdj(ctx context.Context, adj map[int]map[int]int, opts Options) [][]int

CondenseFWBWGroupsFromAdj runs parallel FW–BW SCC on adj and returns only the component groups as slices of original node IDs. This avoids building the idToComp map when callers don't need it.

Types

type CSR

type CSR struct {
	N           int
	Row         []int // len N+1
	Col         []int // len = m
	TRow        []int // len N+1
	TCol        []int // len = m
	IdxToNodeID []int
	NodeIDToIdx map[int]int
}

CSR is a compact adjacency for G and its transpose Gᵗ. Indices are 0..N-1; IdxToNodeID maps back to the original node IDs.

func BuildCSRFromAdj

func BuildCSRFromAdj(adj map[int]map[int]int, opts Options) *CSR

BuildCSRFromAdj constructs CSR/transpose from adjacency map[int]map[int]int. If opts.Deterministic, node IDs are sorted before assigning indices. Isolated nodes must appear as keys in adj (with empty inner map).

type Options

type Options struct {
	// MaxWorkers bounds concurrency for BFS/recursion. Defaults to GOMAXPROCS.
	MaxWorkers int
	// EnableTrim peels vertices with min(in,out)==0 before FW–BW (usually beneficial).
	EnableTrim bool
	// SmallCutoff size below which we switch to a simpler (sequential) routine.
	// You can later swap this to Tarjan for tiny subgraphs.
	SmallCutoff int
	// Deterministic maps node IDs to CSR indices in sorted order (recommended).
	Deterministic bool
}

Options controls parallel SCC execution.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns a sensible baseline.

Jump to

Keyboard shortcuts

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