Documentation ¶
Index ¶
- func BaseID(id string) string
- func ID(parts ...string) string
- func IsDescendentID(parent, child string) bool
- func IsRoot(id string) bool
- func ParentID(id string) string
- func SiblingID(id, sibling string) string
- func SkipModuleAndParams(meta *node.Node) bool
- func Sources(edges []dag.Edge) (sources []string)
- func Targets(edges []dag.Edge) (targets []string)
- type Edge
- type Graph
- func (g *Graph) Add(node *node.Node)
- func (g *Graph) AreSiblings(fst, snd string) bool
- func (g *Graph) Children(id string) (out []string)
- func (g *Graph) Connect(from, to string)
- func (g *Graph) ConnectParent(from, to string)
- func (g *Graph) Contains(id string) bool
- func (g *Graph) Copy() *Graph
- func (g *Graph) Dependencies(id string) []string
- func (g *Graph) Descendents(id string) (out []string)
- func (g *Graph) Disconnect(from, to string)
- func (g *Graph) DownEdges(id string) (out []dag.Edge)
- func (g *Graph) DownEdgesInGroup(id, group string) (out []string)
- func (g *Graph) Edges() []Edge
- func (g *Graph) Get(id string) (*node.Node, bool)
- func (g *Graph) GetParent(id string) (*node.Node, bool)
- func (g *Graph) GetParentID(id string) (string, bool)
- func (g *Graph) GroupNodes(group string) []*node.Node
- func (g *Graph) IsNibling(fst, snd string) bool
- func (g *Graph) Nodes() []*node.Node
- func (g *Graph) Remove(id string)
- func (g *Graph) Root() (string, error)
- func (g *Graph) RootFirstTransform(ctx context.Context, cb TransformFunc) (*Graph, error)
- func (g *Graph) RootFirstWalk(ctx context.Context, cb WalkFunc) error
- func (g *Graph) SafeConnect(from, to string) error
- func (g *Graph) SafeDisconnect(from, to string) error
- func (g *Graph) String() string
- func (g *Graph) Transform(ctx context.Context, cb TransformFunc) (*Graph, error)
- func (g *Graph) UpEdges(id string) (out []dag.Edge)
- func (g *Graph) UpEdgesInGroup(id, group string) (out []string)
- func (g *Graph) Validate() error
- func (g *Graph) Vertices() []string
- func (g *Graph) Walk(ctx context.Context, cb WalkFunc) error
- type Notifier
- type NotifyFunc
- type ParentEdge
- type SkipMergeFunc
- type TransformFunc
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDescendentID ¶
IsDescendentID checks if a child is the descendent of a given parent
func SkipModuleAndParams ¶
SkipModuleAndParams skips trimming modules and params
Types ¶
type Edge ¶
type Edge struct { Source string `json:"source"` Dest string `json:"dest"` Attributes []string `json:"attributes"` }
An Edge is a generic pair of IDs indicating a directed edge in the graph
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a generic graph structure that uses IDs to connect the graph
func MergeDuplicates ¶
MergeDuplicates removes duplicates in the graph
func (*Graph) AreSiblings ¶
AreSiblings returns true if both nodes share a parent edge, or both nodes are at the root of the graph (and have no parent edge). It returns false if both IDs are the same.
func (*Graph) Children ¶
Children returns a list of ids whose parent id is set to the specified node
func (*Graph) ConnectParent ¶
ConnectParent connects a parent node to a child node
func (*Graph) Dependencies ¶
Dependencies gets a list of all dependencies without relying on the ID functions and will work for dependencies that have been added during load.ResolveDependencies
func (*Graph) Descendents ¶
Descendents gets a list of all descendents (not just children, everything) This only works if you're using the hierarchical ID functions from this module.
func (*Graph) Disconnect ¶
Disconnect two vertices by IDs
func (*Graph) DownEdgesInGroup ¶
DownEdgesInGroup returns the outward-facing edges of the specified vertex in the specified group
func (*Graph) Get ¶
Get returns the value of the element and a bool indicating if it was found. If it was not found the value of the returned element is nil, but a valid node will be constructed.
func (*Graph) GetParentID ¶
GetParentID is a combination of getting the parent the getting the ID.
func (*Graph) GroupNodes ¶
GroupNodes will return all nodes in the graph in the specified group
func (*Graph) RootFirstTransform ¶
RootFirstTransform does Transform, but starting at the root
func (*Graph) RootFirstWalk ¶
RootFirstWalk walks the graph root-to-leaf, checking sibling dependencies before descending.
func (*Graph) SafeConnect ¶
SafeConnect connects two vertices together by ID but only if valid
func (*Graph) SafeDisconnect ¶
SafeDisconnect disconnects two vertices by IDs but only if valid
func (*Graph) Transform ¶
Transform a graph of type A to a graph of type B. A and B can be the same.
func (*Graph) UpEdgesInGroup ¶
UpEdgesInGroup returns the outward-facing edges of the specified vertex in the specified group
func (*Graph) Validate ¶
Validate that the graph...
1. has a root 2. has no cycles 3. has no dangling edges
type Notifier ¶
type Notifier struct { Pre NotifyFunc Post NotifyFunc }
Notifier can wrap a graph transform
func (*Notifier) Transform ¶
func (n *Notifier) Transform(inner TransformFunc) TransformFunc
Transform wraps a TransformFunc with this notifier
type ParentEdge ¶
ParentEdge marks an edge as signifying a parent/child relationship
func NewParentEdge ¶
func NewParentEdge(parent, child string) *ParentEdge
NewParentEdge constructs a new ParentEdge between the given vertices
type SkipMergeFunc ¶
SkipMergeFunc will be used to determine whether or not to merge a node
type TransformFunc ¶
TransformFunc is taken by the transformation functions
func NotifyPost ¶
func NotifyPost(post NotifyFunc, inner TransformFunc) TransformFunc
NotifyPost will call a function after walking a node
func NotifyPre ¶
func NotifyPre(pre NotifyFunc, inner TransformFunc) TransformFunc
NotifyPre will call a function before walking a node