graph

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 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 Edge

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

Edge represents a directed connection between two nodes in the graph, with an optional label.

func (*Edge) Class

func (e *Edge) Class() string

Class returns the class of the edge. The class can be used to categorize edges into different types or groups.

func (*Edge) From

func (e *Edge) From() *Node

From returns the source node of the edge.

func (*Edge) Label

func (e *Edge) Label() string

Label returns the label of the edge.

func (*Edge) SetClass

func (e *Edge) SetClass(class string)

SetClass sets the class of the edge.

func (*Edge) SetLabel

func (e *Edge) SetLabel(label string)

SetLabel sets the label of the edge to the given value.

func (*Edge) To

func (e *Edge) To() *Node

To returns the target node of the edge.

type Graph

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

Graph represents an abstraction for a directed graph structure.

func New

func New() *Graph

New creates and returns a new instance of Graph.

func (*Graph) AddNode

func (g *Graph) AddNode(id string) *Node

AddNode adds a new node with the given ID to the graph and returns it. id is a unique identifier for the node. If a node with the same ID already exists, it will be overwritten.

func (*Graph) Node

func (g *Graph) Node(id string) (*Node, bool)

Node returns the node with the given ID if it exists in the graph, otherwise it returns false.

func (*Graph) Nodes

func (g *Graph) Nodes() iter.Seq[*Node]

Nodes implements an interator to allow iterating over all nodes in the graph.

type Node

type Node struct {
	NodeID

	// Label returns the label of the node.
	Label string

	// Description returns the description of the node.
	Description string
	// contains filtered or unexported fields
}

Node represents a vertex in the graph, containing a unique identifier.

func NewNode

func NewNode(id string) *Node

NewNode creates a new node with the given ID and returns it.

func (*Node) AddEdge

func (n *Node) AddEdge(to *Node) *Edge

AddEdge creates a new edge from this node to the specified node and returns it.

func (*Node) Edges

func (n *Node) Edges() []*Edge

Edges returns the outgoing edges for this node.

func (*Node) ID

func (n *Node) ID() string

ID returns the unique identifier of the node.

type NodeID

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

NodeID represents a unique identifier for a node in the graph.

Jump to

Keyboard shortcuts

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