container

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntryFieldSizeBytes  = 8                       // Size of a 64-bit hash
	EntrySizeBytes       = EntryFieldSizeBytes * 2 // Key 64-bit hash + Value 64-bit hash
	DefaultMaxValue      = math.MaxUint64
	DefaultNumMaxEntries = 8_000_000_000
	DefaultNumBuckets    = 1024 * 128
)

Variables

View Source
var (
	ErrUnorderedAppend      = errors.New("unordered append")
	ErrValueOutsideUniverse = errors.New("value outside EFSet universe")
)

Functions

func AdjacentNodes added in v0.4.0

func AdjacentNodes(digraph DirectedGraph, node uint64, direction graph.Direction) []uint64

func Degrees added in v0.4.0

func Degrees(digraph DirectedGraph, node uint64, direction graph.Direction) uint64

func Dimensions added in v0.4.0

func Dimensions(digraph DirectedGraph, direction graph.Direction) (uint64, uint64)

func MarshalSegment added in v0.4.0

func MarshalSegment(segment *Segment, writer io.Writer) error

func Reach added in v0.4.0

func Reach(digraph DirectedGraph, nodeID uint64, direction graph.Direction) cardinality.Duplex[uint64]

func TSBFS added in v0.4.0

func TSBFS(ts Triplestore, nodeID uint64, direction graph.Direction, maxDepth int, descentFilter func(edge Edge) bool, handler func(segment *Segment) bool) int

func TSDFS added in v0.4.0

func TSDFS(ts Triplestore, nodeID uint64, direction graph.Direction, maxDepth int, descentFilter func(edge Edge) bool, handler func(segment *Segment) bool) int

func TSStatelessBFS added in v0.4.0

func TSStatelessBFS(ts Triplestore, rootNode uint64, direction graph.Direction, maxDepth int, descentFilter func(edge Edge) (Weight, bool), terminalHandler func(terminal PathTerminal) bool, numWorkers int) int

SSPBFS is a parallel stateless shortest-path breadth-first search.

Types

type AdjacencyMap

type AdjacencyMap map[uint64]cardinality.Duplex[uint64]

type BFSTreeFile added in v0.4.0

type BFSTreeFile struct {
	Path     string
	NumPaths uint64
}

func WriteZoneBFSTree added in v0.4.0

func WriteZoneBFSTree(zoneNodes graph.NodeSet, ts Triplestore, scratchPath string, maxDepth int) (BFSTreeFile, error)

func (BFSTreeFile) ReadEach added in v0.4.0

func (s BFSTreeFile) ReadEach(ctx context.Context, delegate func(next *Segment) (bool, error)) error

func (BFSTreeFile) Remove added in v0.4.0

func (s BFSTreeFile) Remove() error

type DirectedGraph

type DirectedGraph interface {
	NumNodes() uint64
	EachNode(delegate func(node uint64) bool)
	EachAdjacentNode(node uint64, direction graph.Direction, delegate func(adjacent uint64) bool)
}

func FetchDirectedGraph

func FetchDirectedGraph(ctx context.Context, db graph.Database, criteria graph.Criteria) (DirectedGraph, error)

func FetchFilteredDirectedGraph added in v0.4.0

func FetchFilteredDirectedGraph(ctx context.Context, db graph.Database, traversalKinds ...graph.Kind) (DirectedGraph, error)

type EFSet

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

func AllocateEFSet

func AllocateEFSet(universeMin, universeMax uint64, maxValues uint) *EFSet

func CompressToEFSet

func CompressToEFSet(values []uint64) *EFSet

func NewEFSet

func NewEFSet(universeMin, universeMax uint64, maxValues uint) *EFSet

func (*EFSet) Append

func (s *EFSet) Append(value uint64) error

func (*EFSet) Find

func (s *EFSet) Find(target uint64) (uint, bool)

func (*EFSet) Iterator

func (s *EFSet) Iterator() iter.Seq2[uint, uint64]

func (*EFSet) Len

func (s *EFSet) Len() uint

func (*EFSet) Lookup

func (s *EFSet) Lookup(index uint) uint64

func (*EFSet) MustAppend

func (s *EFSet) MustAppend(value uint64)

type EFSetIterator

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

func NewEFSetIterator

func NewEFSetIterator(vec *EFSet) *EFSetIterator

func (*EFSetIterator) Next

func (s *EFSetIterator) Next() uint64

type Edge added in v0.4.0

type Edge struct {
	ID    uint64
	Start uint64
	End   uint64
}

func (Edge) Pick added in v0.4.0

func (s Edge) Pick(direction graph.Direction) uint64

type KindDatabase added in v0.4.0

type KindDatabase struct {
	EdgeKindMap KindMap
	NodeKindMap KindMap
}

func (KindDatabase) EdgeKind added in v0.4.0

func (s KindDatabase) EdgeKind(edgeID uint64) graph.Kind

func (KindDatabase) NodeKind added in v0.4.0

func (s KindDatabase) NodeKind(nodeID uint64) graph.Kinds

type KindMap added in v0.4.0

type KindMap map[graph.Kind]cardinality.Duplex[uint64]

func (KindMap) Add added in v0.4.0

func (s KindMap) Add(kind graph.Kind, member uint64)

func (KindMap) FindAll added in v0.4.0

func (s KindMap) FindAll(id uint64) graph.Kinds

func (KindMap) FindFirst added in v0.4.0

func (s KindMap) FindFirst(id uint64) graph.Kind

type MutableDirectedGraph added in v0.4.0

type MutableDirectedGraph interface {
	DirectedGraph

	AddNode(node uint64)
	AddEdge(start, end uint64)
}

func BuildAdjacencyMapGraph added in v0.4.3

func BuildAdjacencyMapGraph(adj map[uint64][]uint64) MutableDirectedGraph

func BuildGraph added in v0.4.3

func BuildGraph(constructor func() MutableDirectedGraph, adj map[uint64][]uint64) MutableDirectedGraph

func NewAdjacencyMapGraph added in v0.4.0

func NewAdjacencyMapGraph() MutableDirectedGraph

func NewCSRGraph added in v0.4.0

func NewCSRGraph() MutableDirectedGraph

NewCSRGraph creates an empty mutable directed graph that uses CSR internally.

type MutableTriplestore added in v0.4.0

type MutableTriplestore interface {
	Triplestore

	AddTriple(edge, start, end uint64)
}

func NewTriplestore added in v0.4.0

func NewTriplestore() MutableTriplestore

type PackedMap

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

func NewPacMap

func NewPacMap(parameters Parameters) *PackedMap

func (*PackedMap) Compact

func (s *PackedMap) Compact()

func (*PackedMap) CompactParallel

func (s *PackedMap) CompactParallel(workers int)

func (*PackedMap) Get

func (s *PackedMap) Get(key uint64) (uint64, bool)

func (*PackedMap) Put

func (s *PackedMap) Put(key, value uint64)

type Parameters

type Parameters struct {
	BucketKeyStride uint64
	NumMaxEntries   int
	NumBuckets      int
}

func DefaultParameters

func DefaultParameters() Parameters

type PathTerminal added in v0.4.0

type PathTerminal struct {
	Node     uint64
	Weight   Weight
	Distance int
}

func BFSTree added in v0.4.0

func BFSTree(digraph DirectedGraph, nodeID uint64, direction graph.Direction) []PathTerminal

type Segment added in v0.4.0

type Segment struct {
	Node     uint64
	Edge     uint64
	Previous *Segment
}

func UnmarshalSegment added in v0.4.0

func UnmarshalSegment(segmentBytes []byte) *Segment

func (*Segment) Depth added in v0.4.0

func (s *Segment) Depth() int

func (*Segment) Each added in v0.4.0

func (s *Segment) Each(visitor func(cursor *Segment) bool)

func (*Segment) Edges added in v0.4.0

func (s *Segment) Edges() []uint64

func (*Segment) Format added in v0.4.0

func (s *Segment) Format() string

func (*Segment) Nodes added in v0.4.0

func (s *Segment) Nodes() []uint64

func (*Segment) Root added in v0.4.0

func (s *Segment) Root() uint64

func (*Segment) Trunk added in v0.4.0

func (s *Segment) Trunk() uint64

Trunk returns the edge closest to the root node of the segment

type SerializedSegment added in v0.4.0

type SerializedSegment struct {
	Nodes []uint64
	Edges []uint64
}

func (SerializedSegment) ToSegment added in v0.4.0

func (s SerializedSegment) ToSegment() *Segment

type Triplestore added in v0.4.0

type Triplestore interface {
	DirectedGraph

	NumEdges() uint64
	EachEdge(delegate func(next Edge) bool)
	EachAdjacentEdge(node uint64, direction graph.Direction, delegate func(next Edge) bool)

	Projection(deletedNodes, deletedEdges cardinality.Duplex[uint64]) Triplestore
}

type Weight

type Weight = float64

Jump to

Keyboard shortcuts

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