graph

package
v0.0.0-...-157f31e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DAG

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

DAG 有向无环图的实现

func NewDAG

func NewDAG() *DAG

NewDAG 创建新的DAG

func (*DAG) AddEdge

func (d *DAG) AddEdge(edge core.Edge) error

AddEdge 添加边到图中

func (*DAG) AddNode

func (d *DAG) AddNode(node core.Node) error

AddNode 添加节点到图中

func (*DAG) ConnectNode

func (d *DAG) ConnectNode(node1, node2 core.Node) error

ConnectNode 连接两个节点

func (*DAG) Edges

func (d *DAG) Edges() []core.Edge

Edges 返回所有边

func (*DAG) FindEdgeById

func (d *DAG) FindEdgeById(edgeId string) (core.Edge, bool)

FindEdgeById 根据ID查找边

func (*DAG) FindNodeById

func (d *DAG) FindNodeById(nodeId string) (core.Node, bool)

FindNodeById 根据ID查找节点

func (*DAG) GetPredecessors

func (d *DAG) GetPredecessors(nodeID string) []*Edge

GetPredecessors 获取节点的前驱边

func (*DAG) GetSuccessors

func (d *DAG) GetSuccessors(nodeID string) []*Edge

GetSuccessors 获取节点的后继边

func (*DAG) Nodes

func (d *DAG) Nodes() []core.Node

Nodes 返回所有节点

func (*DAG) TopologicalSort

func (d *DAG) TopologicalSort() ([]core.Node, error)

TopologicalSort 返回拓扑排序后的节点列表

func (*DAG) ValidateComplete

func (d *DAG) ValidateComplete() error

ValidateComplete 执行完整的图验证

func (*DAG) ValidateConnectivity

func (d *DAG) ValidateConnectivity() error

ValidateConnectivity 验证图的连通性

func (*DAG) ValidateDAG

func (d *DAG) ValidateDAG() error

ValidateDAG 验证DAG的有效性(无环检查)

func (*DAG) ValidateNoSelfLoops

func (d *DAG) ValidateNoSelfLoops() error

ValidateNoSelfLoops 验证没有自环

func (*DAG) ValidateNodeReferences

func (d *DAG) ValidateNodeReferences() error

ValidateNodeReferences 验证节点引用的一致性

type Edge

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

Edge 边的实现

func NewEdge

func NewEdge(sourceNode, targetNode core.Node) *Edge

NewEdge 创建新的边

func (*Edge) ID

func (e *Edge) ID() string

ID 返回边的唯一标识符

func (*Edge) SetID

func (e *Edge) SetID(id string)

SetID 设置边的ID

func (*Edge) SourceNodeId

func (e *Edge) SourceNodeId() string

SourceNodeId 返回源节点ID

func (*Edge) TargetNodeId

func (e *Edge) TargetNodeId() string

TargetNodeId 返回目标节点ID

Jump to

Keyboard shortcuts

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