Documentation ¶
Index ¶
- type Graph
- func (g *Graph) AddEdge(from, to string) int
- func (g *Graph) AddNode(name string) bool
- func (g *Graph) AddNodes(names ...string) bool
- func (g *Graph) BreadthSort() []string
- func (g *Graph) Copy() *Graph
- func (g *Graph) DebugDump() string
- func (g *Graph) FindChildren(from string) []string
- func (g *Graph) FindCycle(seed string) []string
- func (g *Graph) FindParents(to string) []string
- func (g *Graph) ReindexNode(node string)
- func (g *Graph) RemoveEdge(from, to string) bool
- func (g *Graph) Serialize(sorted []string) string
- func (g *Graph) Toposort() ([]string, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a directed acyclic graph.
func (*Graph) AddEdge ¶
AddEdge inserts the link from "from" node to "to" node.
func (*Graph) AddNode ¶
AddNode inserts a new node into the graph.
func (*Graph) AddNodes ¶
AddNodes inserts multiple nodes into the graph at once.
func (*Graph) BreadthSort ¶
BreadthSort sorts the nodes in the graph in BFS order.
func (*Graph) Copy ¶
Copy clones the graph and returns the independent copy.
func (*Graph) DebugDump ¶
DebugDump converts the graph to a string. As the name suggests, useful for debugging.
func (*Graph) FindChildren ¶
FindChildren returns the other ends of outgoing edges.
func (*Graph) FindCycle ¶
FindCycle returns the cycle in the graph which contains "seed" node.
func (*Graph) FindParents ¶
FindParents returns the other ends of incoming edges.
func (*Graph) ReindexNode ¶
ReindexNode updates the internal representation of the node after edge removals.
func (*Graph) RemoveEdge ¶
RemoveEdge deletes the link from "from" node to "to" node. Call ReindexNode(from) after you finish modifying the edges.
func (*Graph) Serialize ¶
Serialize outputs the graph in Graphviz format.