Documentation
¶
Index ¶
- type Edge
- type Graph
- func (g *Graph[EdgeType, VertexType]) AddEdge(from, to VertexType, edge EdgeType) error
- func (g *Graph[EdgeType, VertexType]) GetForwardAdjacentVertices(from VertexType) []Edge[EdgeType, VertexType]
- func (g *Graph[EdgeType, VertexType]) GetReverseAdjacentVertices(to VertexType) []Edge[EdgeType, VertexType]
- func (g *Graph[EdgeType, VertexType]) ToDOT(name string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Edge ¶
type Edge[EdgeType, VertexType comparable] struct { From VertexType To VertexType Edge EdgeType }
Edge is a convenience type for representing an edge in the graph. It encapsulates the from and to vertices and the edge type itself.
type Graph ¶
type Graph[EdgeType, VertexType comparable] struct { // contains filtered or unexported fields }
Graph provides a bidirectional interface over gonum's directed graph implementation. While the underlying gonum graph is directed, we overlay bidirectional semantics by distinguishing between forward and reverse edges. Wanting and being wanted by other units are related but different concepts that have different graph traversal implications when Units update their status.
The graph stores edge types to represent different relationships between units, allowing for domain-specific semantics beyond simple connectivity.
func (*Graph[EdgeType, VertexType]) AddEdge ¶
AddEdge adds an edge to the graph. It initializes the graph and metadata on first use, checks for cycles, and adds the edge to the gonum graph.
func (*Graph[EdgeType, VertexType]) GetForwardAdjacentVertices ¶
func (g *Graph[EdgeType, VertexType]) GetForwardAdjacentVertices(from VertexType) []Edge[EdgeType, VertexType]
GetForwardAdjacentVertices returns all the edges that originate from the given vertex.
func (*Graph[EdgeType, VertexType]) GetReverseAdjacentVertices ¶
func (g *Graph[EdgeType, VertexType]) GetReverseAdjacentVertices(to VertexType) []Edge[EdgeType, VertexType]
GetReverseAdjacentVertices returns all the edges that terminate at the given vertex.