Documentation
¶
Overview ¶
Package graph provides a simple adjacency map graph for network-graph.
Index ¶
- func Save(g *Graph) (string, error)
- type Graph
- func (g *Graph) AddEdge(from, to NodeID) error
- func (g *Graph) AddNode(id NodeID) error
- func (g *Graph) EdgeCount() int
- func (g *Graph) HasEdge(from, to NodeID) bool
- func (g *Graph) HasNode(id NodeID) bool
- func (g *Graph) Hash() string
- func (g *Graph) IsBidirectional() bool
- func (g *Graph) IsUndirected() bool
- func (g *Graph) Neighbors(id NodeID) []NodeID
- func (g *Graph) Nodes() []NodeID
- func (g *Graph) RemoveEdge(from, to NodeID) error
- func (g *Graph) RemoveNode(id NodeID) error
- type NodeID
- type Path
- type PathLength
- type Paths
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph maintains nodes and adjacency edges.
func FromMatrix ¶
FromMatrix creates a new graph from a boolean adjacency matrix.
func (*Graph) AddEdge ¶
AddEdge adds an edge from -> to. If bidirectional is true, adds the reverse edge as well.
func (*Graph) IsBidirectional ¶
[deprecated] This function is deprecated. Use graph.IsUndirected() instead. IsBidirectional returns true if the graph is bidirectional.
func (*Graph) IsUndirected ¶
IsUndirected returns true if the graph is undirected.
func (*Graph) RemoveEdge ¶
RemoveEdge removes the edge from -> to. If bidirectional is true, removes the reverse edge as well.
func (*Graph) RemoveNode ¶
RemoveNode removes a node and its incident edges from the graph.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path represents an ordered sequence of nodes with a hop distance.
func NewPath ¶
New constructs a Path from the given nodes. Distance is hops (edges). If no nodes are provided, the path is considered infinite (unreachable).
func (*Path) IsInfinite ¶
IsInfinite reports whether the path is infinite (unreachable).
type PathLength ¶
PathLength represents the length of a path between two nodes.
type Paths ¶
Paths is a mapping of start node IDs to end node IDs and their corresponding paths.
func (Paths) OnlyLength ¶
func (g Paths) OnlyLength() PathLength
OnlyLength returns a slice of PathLength representing the lengths of all paths in the graph.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package algorithm provides graph algorithms for network analysis.
|
Package algorithm provides graph algorithms for network analysis. |
|
Package standard_graph provides a standard implementation of a graph data structure.
|
Package standard_graph provides a standard implementation of a graph data structure. |