graph

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph[T Node] struct {
	// contains filtered or unexported fields
}

Graph is a directed, cyclic, unweighted graph.

func New

func New[T Node]() *Graph[T]

func (*Graph[T]) Edges

func (g *Graph[T]) Edges() map[string]map[string]bool

func (*Graph[T]) InsertGraph

func (g *Graph[T]) InsertGraph(other *Graph[T])

InsertGraph merges other into g.

func (*Graph[T]) InsertTree

func (g *Graph[T]) InsertTree(nodes ...T)

InsertTree inserts nodes of a tree, ordered root first, leaf last.

func (*Graph[T]) Nodes

func (g *Graph[T]) Nodes() []T

func (*Graph[T]) Roots

func (g *Graph[T]) Roots() []T

func (*Graph[T]) String

func (g *Graph[T]) String() string

func (*Graph[T]) Subgraph

func (g *Graph[T]) Subgraph(rootID string) *Graph[T]

type Node

type Node interface {
	// ID uniquely identifies this node. Any node with the same ID is expected to
	// contain the exact same data.
	ID() string
}

Jump to

Keyboard shortcuts

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