Documentation
¶
Index ¶
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 is a directed graph for use with the DAG policy. Graph only represents edge relationships. There is no notion of node existence.
func (Graph) AddEdge ¶
AddEdge adds an edge between node1 and node2. Edges are directional, so this will add node2 to node1's neighbour set, but will not add node1 to node2's neighbour set. Self-connections are allowed and will be detected as a cycle. This function is idempotent.
func (Graph) HasCycle ¶
HasCycle searches for cycles in the graph. If one or more cycles exists, one of the cycles is returned at random. If no cycle exists, returns nil, false. Returned cycles are in the form of a list of nodes, where subsequent nodes are connected in the graph, and the last element is connected to the first element.
func (Graph) Neighbours ¶
Neighbours returns the neighbours of a node. A neighbour relationship is directional. If only the edge a->b exists, then Neighbours(a) will include b, but Neighbours(b) will not include a.