Help us shape the future of Go! Take the 2026 Go Developer Survey

algorithms

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string

Category represents the Tree of Science classification of a work node.

const (
	// CategoryNone indicates that the work is not classified into any Tree of Science category.
	CategoryNone Category = "none"
	// CategoryRoot indicates foundational, seminal works that established the research field.
	CategoryRoot Category = "root"
	// CategoryTrunk indicates structural backbone papers that consolidate the research topic.
	CategoryTrunk Category = "trunk"
	// CategoryLeaf indicates recent, specialized developments representing the research frontier.
	CategoryLeaf Category = "leaf"
)

type PseudoSteiner

type PseudoSteiner[K comparable] struct {
	// contains filtered or unexported fields
}

PseudoSteiner is a struct that represents a pseudo-steiner algorithm.

func NewPseudoSteiner

func NewPseudoSteiner[K comparable](graph gograph.Graph[K], opts ...PseudoSteinerOption[K]) (*PseudoSteiner[K], error)

NewPseudoSteiner creates a new PseudoSteiner instance.

It takes linear or amortized O(V + E) time to prepare the pseudo-steiner structure.

func (*PseudoSteiner[K]) Run

func (q *PseudoSteiner[K]) Run(terminals []K) (gograph.Graph[K], error)

Run runs the pseudo-steiner algorithm on the given terminals and returns the resulting graph.

Go figure what the complexity is. But don't call this with a large number of terminals.

type PseudoSteinerOption

type PseudoSteinerOption[K comparable] func(*PseudoSteiner[K])

PseudoSteinerOption configures a PseudoSteiner algorithm instance.

func WithMaxEffort

func WithMaxEffort[K comparable](maxEffort float64) PseudoSteinerOption[K]

WithMaxEffort sets the maximum effort for the pseudo-steier algorithm.

func WithMaxEffortExceeded added in v0.2.0

func WithMaxEffortExceeded[K comparable](maxEffortExceeded int) PseudoSteinerOption[K]

WithMaxEffortExceeded sets the maximum number of consecutive candidates exceeding maxEffort before aborting search for a pair.

type Sap

type Sap struct {
	// contains filtered or unexported fields
}

Sap represents the Tree of Science SAP algorithm for citation network analysis. It calculates rootness, trunkness, and leafness scores to classify works into roots, trunk, and leaves.

func NewSapAlgorithm

func NewSapAlgorithm(graph gograph.Graph[string], opts ...SapOption) (*Sap, error)

NewSapAlgorithm creates a new instance of the Sap algorithm for the given directed citation graph. It computes topological orders required for sap flow simulations. Returns an error if the graph is undirected or contains cycles.

func (*Sap) Run

func (s *Sap) Run() (*SapResult, error)

Run executes the SAP algorithm and returns the SapResult containing work categories and scores.

type SapOption

type SapOption func(*Sap)

SapOption configures a Sap algorithm instance.

func WithLeaves

func WithLeaves(leaves int) SapOption

WithLeaves sets the maximum number of leaf nodes to select.

func WithRoots

func WithRoots(roots int) SapOption

WithRoots sets the maximum number of root nodes to select.

func WithTrunks

func WithTrunks(trunks int) SapOption

WithTrunks sets the maximum number of trunk nodes to select.

type SapResult

type SapResult struct {
	Categories map[string]Category
	Rootness   map[string]float64
	Trunkness  map[string]float64
	Leafness   map[string]float64
}

SapResult contains the outcome of the SAP algorithm, including category assignments and metric scores (rootness, trunkness, and leafness) for each vertex in the graph.

Jump to

Keyboard shortcuts

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