Imports #
"cmp"
"fmt"
"slices"
"strings"
"cmp"
"fmt"
"slices"
"strings"
type syntaxError string
type Graph struct {
Nodes []string
byLabel map[string]int
edges map[string]map[string]bool
}
A rule is a line in the DAG language where "less < def" or "less !< def".
type rule struct {
less []string
op string
def []string
}
A rulesParser parses the depsRules syntax described above.
type rulesParser struct {
lineno int
lastWord string
text string
}
func (g *Graph) AddEdge(from string, to string)
func (g *Graph) DelEdge(from string, to string)
func (g *Graph) Edges(from string) []string
func (e syntaxError) Error() string
func (g *Graph) HasEdge(from string, to string) bool
Parse parses the DAG language and returns the transitive closure of the described graph. In the returned graph, there is an edge from "b" to "a" if b < a (or a > b) in the partial order.
func Parse(dag string) (*Graph, error)
Topo returns a topological sort of g. This function is deterministic.
func (g *Graph) Topo() []string
TransitiveReduction removes edges from g that are transitively reachable. g must be transitively closed.
func (g *Graph) TransitiveReduction()
Transpose reverses all edges in g.
func (g *Graph) Transpose()
func (g *Graph) addNode(label string) bool
func newGraph() *Graph
nextList parses and returns a comma-separated list of names.
func (p *rulesParser) nextList() (list []string, token string)
nextToken returns the next token in the deps rules, one of ";" "," "<" "!<" or a name.
func (p *rulesParser) nextToken() string
parseRules parses the rules of a DAG.
func parseRules(rules string) (out []rule, err error)
syntaxError reports a parsing error.
func (p *rulesParser) syntaxError(msg string)
Generated with Arrow