Documentation
¶
Index ¶
- func BuildGraphWithDFS[K comparable, T comparable](ctx context.Context, startNode T, getNodeKey func(T) (K, error), ...) error
- func GraphPath[T comparable](node T, next func(T) []T) [][]T
- func GraphPathEx[K comparable, T, U any](ctx context.Context, node T, next func(T) []T, getKey func(T) K, ...) [][]U
- func GraphPathWithKey[K comparable, T any](node T, next func(T) []T, getKey func(T) K) [][]T
- func GraphPathWithTarget[T comparable](ctx context.Context, node T, target T, next func(T) []T) [][]T
- func GraphPathWithValue[T comparable, U any](node T, next func(T) []T, getValue func(T) U) [][]U
- type DFSGraphBuilder
- type DeepFirstPath
- type Neighbor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildGraphWithDFS ¶
func BuildGraphWithDFS[K comparable, T comparable]( ctx context.Context, startNode T, getNodeKey func(T) (K, error), getNeighbors func(T) []*Neighbor[T], handleEdge func(from K, to K, edgeType string, extraMsg map[string]any), ) error
func GraphPath ¶
func GraphPath[T comparable]( node T, next func(T) []T, ) [][]T
index by T type , and return path with T type
func GraphPathEx ¶
func GraphPathEx[K comparable, T, U any]( ctx context.Context, node T, next func(T) []T, getKey func(T) K, getValue func(T) U, target ...T, ) [][]U
func GraphPathWithKey ¶
func GraphPathWithKey[K comparable, T any]( node T, next func(T) []T, getKey func(T) K, ) [][]T
index by K type, and return path with T type
func GraphPathWithTarget ¶
func GraphPathWithTarget[T comparable]( ctx context.Context, node T, target T, next func(T) []T, ) [][]T
func GraphPathWithValue ¶
func GraphPathWithValue[T comparable, U any]( node T, next func(T) []T, getValue func(T) U, ) [][]U
index by T type, and return path with U type
Types ¶
type DFSGraphBuilder ¶
type DFSGraphBuilder[K, T comparable] struct { // contains filtered or unexported fields }
DFSGraphBuilder is a utility struct to construct a graph using Depth-First Search (DFS) traversal.
func NewDFSGraphBuilder ¶
func NewDFSGraphBuilder[K comparable, T comparable]( ctx context.Context, getNodeKey func(T) (K, error), getNeighbors func(T) []*Neighbor[T], handleEdge func(from K, to K, edgeType string, extraMsg map[string]any), ) *DFSGraphBuilder[K, T]
func (*DFSGraphBuilder[K, T]) BuildGraph ¶
func (g *DFSGraphBuilder[K, T]) BuildGraph(startNode T) error
BuildGraph Depth-First Search driven graph construction method
func (*DFSGraphBuilder[K, T]) GetVisited ¶
func (g *DFSGraphBuilder[K, T]) GetVisited(node T) (key K, ok bool)
type DeepFirstPath ¶
type DeepFirstPath[K comparable, T, U any] struct { // contains filtered or unexported fields }
deep first search for nodeID and its children to [][]id, id is string, if node.Prev have more than one, add a new line
type Neighbor ¶
type Neighbor[T any] struct { // The neighboring node Node T // The type of edge connecting the current node to the neighbor EdgeType string ExtraMsg map[string]any }
Neighbor Structure combining neighboring nodes with their edge types
func NewNeighbor ¶
func (*Neighbor[T]) AddExtraMsg ¶
Click to show internal directories.
Click to hide internal directories.