Documentation
¶
Overview ¶
Package dag implements a Directed Acyclic Graph for Package dependencies.
Package dag implements a Directed Acyclic Graph for Package dependencies.
Index ¶
- type DAG
- type MapDag
- func (d *MapDag) AddEdge(from string, to Node) (bool, error)
- func (d *MapDag) AddEdges(edges map[string][]Node) ([]Node, error)
- func (d *MapDag) AddNode(node Node) error
- func (d *MapDag) AddNodes(nodes ...Node) error
- func (d *MapDag) AddOrUpdateNodes(nodes ...Node)
- func (d *MapDag) GetNode(identifier string) (Node, error)
- func (d *MapDag) Init(nodes []Node) ([]Node, error)
- func (d *MapDag) NodeExists(identifier string) bool
- func (d *MapDag) NodeNeighbors(identifier string) ([]Node, error)
- func (d *MapDag) Sort() ([]string, error)
- func (d *MapDag) TraceNode(identifier string) (map[string]Node, error)
- type MapUpgradingDag
- func (d *MapUpgradingDag) AddEdge(from string, to Node) (bool, error)
- func (d *MapUpgradingDag) AddEdges(edges map[string][]Node) ([]Node, error)
- func (d *MapUpgradingDag) AddNode(node Node) error
- func (d *MapUpgradingDag) AddNodes(nodes ...Node) error
- func (d *MapUpgradingDag) AddOrUpdateNodes(nodes ...Node)
- func (d *MapUpgradingDag) GetNode(identifier string) (Node, error)
- func (d *MapUpgradingDag) Init(nodes []Node) ([]Node, error)
- func (d *MapUpgradingDag) NodeExists(identifier string) bool
- func (d *MapUpgradingDag) NodeNeighbors(identifier string) ([]Node, error)
- func (d *MapUpgradingDag) Sort() ([]string, error)
- func (d *MapUpgradingDag) TraceNode(identifier string) (map[string]Node, error)
- type NewDAGFn
- type NewUpgradingDAGFn
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DAG ¶
type DAG interface {
Init(ns []Node) ([]Node, error)
AddNode(n Node) error
AddNodes(ns ...Node) error
AddOrUpdateNodes(ns ...Node)
GetNode(identifier string) (Node, error)
AddEdge(from string, to Node) (bool, error)
AddEdges(edges map[string][]Node) ([]Node, error)
NodeExists(identifier string) bool
NodeNeighbors(identifier string) ([]Node, error)
TraceNode(identifier string) (map[string]Node, error)
Sort() ([]string, error)
}
DAG is a Directed Acyclic Graph.
func NewUpgradingMapDag ¶ added in v1.18.0
func NewUpgradingMapDag() DAG
NewUpgradingMapDag creates a new MapDag.
type MapDag ¶
type MapDag struct {
// contains filtered or unexported fields
}
MapDag is a directed acyclic graph implementation that uses a map for its underlying data structure.
func (*MapDag) AddOrUpdateNodes ¶
AddOrUpdateNodes adds new nodes or updates the existing ones with the same identifier.
func (*MapDag) Init ¶
Init initializes a MapDag and implies missing destination nodes. Any implied nodes are returned. Any existing nodes are cleared.
func (*MapDag) NodeExists ¶
NodeExists checks whether a node exists.
func (*MapDag) NodeNeighbors ¶
NodeNeighbors returns a node's neighbors.
type MapUpgradingDag ¶ added in v1.18.0
type MapUpgradingDag struct {
// contains filtered or unexported fields
}
MapUpgradingDag is a directed acyclic graph implementation that uses a map for its underlying data structure and has the ability to distinguish upgradable nodes.
func (*MapUpgradingDag) AddEdge ¶ added in v1.18.0
func (d *MapUpgradingDag) AddEdge(from string, to Node) (bool, error)
AddEdge adds an edge to the graph and returns if we need to check for updates.
func (*MapUpgradingDag) AddEdges ¶ added in v1.18.0
func (d *MapUpgradingDag) AddEdges(edges map[string][]Node) ([]Node, error)
AddEdges adds edges to the graph.
func (*MapUpgradingDag) AddNode ¶ added in v1.18.0
func (d *MapUpgradingDag) AddNode(node Node) error
AddNode adds a node to the graph.
func (*MapUpgradingDag) AddNodes ¶ added in v1.18.0
func (d *MapUpgradingDag) AddNodes(nodes ...Node) error
AddNodes adds nodes to the graph.
func (*MapUpgradingDag) AddOrUpdateNodes ¶ added in v1.18.0
func (d *MapUpgradingDag) AddOrUpdateNodes(nodes ...Node)
AddOrUpdateNodes adds new nodes or updates the existing ones with the same identifier.
func (*MapUpgradingDag) GetNode ¶ added in v1.18.0
func (d *MapUpgradingDag) GetNode(identifier string) (Node, error)
GetNode returns a node in the dag.
func (*MapUpgradingDag) Init ¶ added in v1.18.0
func (d *MapUpgradingDag) Init(nodes []Node) ([]Node, error)
Init initializes a MapDag and implies missing destination nodes. Any implied nodes are returned. Any existing nodes are cleared.
func (*MapUpgradingDag) NodeExists ¶ added in v1.18.0
func (d *MapUpgradingDag) NodeExists(identifier string) bool
NodeExists checks whether a node exists.
func (*MapUpgradingDag) NodeNeighbors ¶ added in v1.18.0
func (d *MapUpgradingDag) NodeNeighbors(identifier string) ([]Node, error)
NodeNeighbors returns a node's neighbors.
func (*MapUpgradingDag) Sort ¶ added in v1.18.0
func (d *MapUpgradingDag) Sort() ([]string, error)
Sort performs topological sort on the graph.
type NewUpgradingDAGFn ¶ added in v1.18.0
type NewUpgradingDAGFn func() DAG
NewUpgradingDAGFn is a function that returns a DAG.
type Node ¶
type Node interface {
Identifier() string
Neighbors() []Node
// GetConstraints Returns the version or constraint of the package.
GetConstraints() string
// GetParentConstraints Returns the version or constraint of the package which comes from its parents.
GetParentConstraints() []string
AddParentConstraints(c []string)
// Node implementations should be careful to establish uniqueness of
// neighbors in their AddNeighbors method or risk counting a neighbor
// multiple times.
AddNeighbors(ns ...Node) error
}
Node is a node in DAG.