Package graph
Table of Contents
Dependencies
-
eudaimonia/uuid
Types
Functions
graph.ContainsNode
graph/graph.go
func (g *Graph) ContainsNode(n *Node) bool
Parameters:
-
v: Checks if g contains the vertex v.
Returns:
-
true if v is in g.
-
false if v is not in g.
Example:
g := graph.NewGraph()
n := g.NewNode()
fmt.Println(g.Contains(n)) // true
graph.GetNodes
graph/graph.go
func (g *Graph) GetNodes() []*Node
Returns all nodes within the graph g.
graph.InsertDirectedEdge
graph/graph.go
func (g *Graph) InsertDirectedEdge(src, dst *Node) (*Edge, error)
Returns:
-
nilif the operation was successful. -
error:-
If either src or dst does not exist within g.
-
If the edge already exists in g.
-
graph.ContainsEdge
graph/graph.go
func (g *graph) ContainsEdge(e *Edge) bool
Parameters:
-
e: Checks if g contains the edge e.
Returns:
-
true if e is in g.
-
false if e is not in g.
Example:
g := graph.NewGraph()
v := g.NewNode()
w := g.NewNode()
e := g.InsertDirectedEdge(v, w)
fmt.Println(g.ContainsEdge(e)) // true
graph.GetPath
graph/graph.go
=== func (g *Graph) GetPath(src, dst *Node) ([]*Node, error)
Returns the path from the source node to the destination node.
Parameters:
-
src: The source node of the path.
-
dst: The destination node of the path.
Returns:
Returns an array of *Node,
including src and dst
or an error if src or dst are not in g
or there is no path connecting them.