graph

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	// New returns a new graph
	New() Graph
}

Factory creates new graphs

type Graph

type Graph interface {
	// Add adds a vertex to the graph
	Add(vertex ids.ID)

	// Remove removes a vertex from the graph
	Remove(vertex ids.ID)

	// AddEdge adds an edge from u to v
	AddEdge(u, v ids.ID)

	// RemoveEdge removes the edge from u to v
	RemoveEdge(u, v ids.ID)

	// Neighbors returns the neighbors of a vertex
	Neighbors(vertex ids.ID) set.Set[ids.ID]

	// HasEdge returns true if there is an edge from u to v
	HasEdge(u, v ids.ID) bool

	// Vertices returns all vertices in the graph
	Vertices() set.Set[ids.ID]

	// Len returns the number of vertices
	Len() int
}

Graph represents a directed graph

type Topological

type Topological interface {
	Graph

	// TopologicalSort returns a topological ordering of the graph
	TopologicalSort() ([]ids.ID, error)

	// HasCycle returns true if the graph has a cycle
	HasCycle() bool

	// StronglyConnectedComponents returns the strongly connected components
	StronglyConnectedComponents() []set.Set[ids.ID]
}

Topological provides topological operations on graphs

type Tx

type Tx interface {
	// ID returns the transaction ID
	ID() ids.ID

	// Inputs returns the input IDs
	Inputs() set.Set[ids.ID]

	// Outputs returns the output IDs
	Outputs() set.Set[ids.ID]

	// Bytes returns the binary representation
	Bytes() []byte
}

Tx represents a transaction in the graph

Jump to

Keyboard shortcuts

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