path

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package path defines path structures used by network-graph algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphPaths

type GraphPaths map[node.ID]map[node.ID][]Path

GraphPaths is a mapping of start node IDs to end node IDs and their corresponding paths.

func (GraphPaths) OnlyLength

func (g GraphPaths) OnlyLength() PathLength

OnlyLength returns a slice of PathLength representing the lengths of all paths in the graph.

type Path

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

Path represents an ordered sequence of nodes with a hop distance.

func New

func New(nodes ...node.ID) *Path

New constructs a Path from the given nodes. Distance is hops (edges). If no nodes are provided, the path is considered infinite (unreachable).

func NewSelf

func NewSelf(id node.ID) *Path

NewSelf constructs a new Path representing a self-loop at the given node.

func (*Path) Distance

func (p *Path) Distance() int

Distance returns the hop distance of the path.

func (*Path) IsInfinite

func (p *Path) IsInfinite() bool

IsInfinite reports whether the path is infinite (unreachable).

func (*Path) Nodes

func (p *Path) Nodes() []node.ID

Nodes returns the node IDs in the path.

type PathLength

type PathLength map[node.ID]map[node.ID]int

PathLength represents the length of a path between two nodes.

Jump to

Keyboard shortcuts

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