Movatterモバイル変換


[0]ホーム

URL:


dag

packagestandard library
go1.25.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:4Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

Package dag implements a language for expressing directed acyclicgraphs.

The general syntax of a rule is:

a, b < c, d;

which means c and d come after a and b in the partial order(that is, there are edges from c and d to a and b),but doesn't provide a relative order between a vs b or c vs d.

The rules can chain together, as in:

e < f, g < h;

which is equivalent to

e < f, g;f, g < h;

Except for the special bottom element "NONE", each namemust appear exactly once on the right-hand side of any rule.That rule serves as the definition of the allowed successorfor that name. The definition must appear before any usesof the name on the left-hand side of a rule. (That is, therules themselves must be ordered according to the partialorder, for easier reading by people.)

Negative assertions double-check the partial order:

i !< j

means that it must NOT be the case that i < j.Negative assertions may appear anywhere in the rules,even before i and j have been defined.

Comments begin with #.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeGraph

type Graph struct {Nodes []string// contains filtered or unexported fields}

funcParse

func Parse(dagstring) (*Graph,error)

Parse parses the DAG language and returns the transitive closure ofthe 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 (*Graph)AddEdge

func (g *Graph) AddEdge(from, tostring)

func (*Graph)DelEdge

func (g *Graph) DelEdge(from, tostring)

func (*Graph)Edges

func (g *Graph) Edges(fromstring) []string

func (*Graph)HasEdge

func (g *Graph) HasEdge(from, tostring)bool

func (*Graph)Topo

func (g *Graph) Topo() []string

Topo returns a topological sort of g. This function is deterministic.

func (*Graph)TransitiveReduction

func (g *Graph) TransitiveReduction()

TransitiveReduction removes edges from g that are transitivelyreachable. g must be transitively closed.

func (*Graph)Transpose

func (g *Graph) Transpose()

Transpose reverses all edges in g.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp