Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
Node is a simple node for a digraph
func NodesFromEdges ¶
NodesFromEdges make a Node based adjacency list from edges calculating the heads' indegree.
func TopoOrder ¶
TopoOrder takes an adjacency list and returns nodes in topological order iterate over node list, finding all with indegree zero.
- calculate the indegree while building the adjacency list from the edge list, every time you connect a tail, to a head, increment the indegree of the head.
add them to a stack. While the stack is not empty pop a node of the stack and conceptually remove it from the graph. for every outbound node, decrement that node's indegree and if that node then has indegree zero, add it to the stack append the node to order.
Click to show internal directories.
Click to hide internal directories.