Documentation ¶
Overview ¶
Package portgraph searches for a graph that satisfies a set of constraints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbstractEdge ¶
type AbstractEdge struct {
Src, Dst *AbstractPort
}
AbstractEdge represents a link from an source AbstractPort to a destination AbstractPort.
func (*AbstractEdge) String ¶
func (e *AbstractEdge) String() string
type AbstractGraph ¶
type AbstractGraph struct { Desc string // Description for the AbstractGraph for logging. Nodes []*AbstractNode Edges []*AbstractEdge }
AbstractGraph is a representation of abstract nodes, ports, and edges.
type AbstractNode ¶
type AbstractNode struct { Desc string // Description for the AbstractNode for logging. Ports []*AbstractPort // A list AbstractPorts that may be connected to another AbstractPort. Constraints map[string]NodeConstraint // A map of key value constraints of the AbstractNode. }
AbstractNode represent a vertex on an AbstractGraph. The AbstractNode has AbstractPorts and AbstractEdges that originate and terminate at AbstractPorts.
type AbstractPort ¶
type AbstractPort struct { Desc string // Description for the AbstractPort for logging. Constraints map[string]PortConstraint // A map of key value constraints of the AbstractPort. }
AbstractPort is a is point on an AbstractNode where an AbstractEdge may be attached.
type Assignment ¶
type Assignment struct { Node2Node map[*AbstractNode]*ConcreteNode Port2Port map[*AbstractPort]*ConcretePort }
Assignment contains the AbstractNode -> ConcreteNode and AbstractPort -> ConcretePort mappings.
func Solve ¶
func Solve(abstractGraph *AbstractGraph, superGraph *ConcreteGraph) (*Assignment, error)
Solve returns an assignment from superGraph that satisfies abstractGraph.
type ConcreteEdge ¶
type ConcreteEdge struct {
Src, Dst *ConcretePort
}
ConcreteEdge represents a link from an source ConcretePort to a destination ConcretePort.
type ConcreteGraph ¶
type ConcreteGraph struct { Desc string // Description for the AbstractGraph for logging. Nodes []*ConcreteNode Edges []*ConcreteEdge }
ConcreteGraph is a representation of concrete nodes, ports, and edges.
type ConcreteNode ¶
type ConcreteNode struct { Desc string // Description for the ConcreteNode for logging. Ports []*ConcretePort // A list ConcretePorts that may be connected to another ConcretePort. Attrs map[string]string // A map of key value attributes of the ConctreteNode. }
ConcreteNode represent a vertex on a ConcreteGraph. The ConcreteNode has ConcretePorts and ConcreteEdges that originate and terminate at ConcretePorts.
type ConcretePort ¶
type ConcretePort struct { Desc string // Description for the ConcretePort for logging. Attrs map[string]string // A map of key value attributes of the ConcretePort. }
ConcretePort is a is point on a ConcreteNode where a ConcreteEdge may be attached.
type LeafConstraint ¶
type LeafConstraint interface {
// contains filtered or unexported methods
}
LeafConstraint is a constraint checker that checks the input matches based on some matching criteria.
func Equal ¶
func Equal(s string) LeafConstraint
Equal returns a constraint that an attribute is equal to the specified string.
func NotEqual ¶
func NotEqual(s string) LeafConstraint
NotEqual returns a constraint that an attribute is not equal to the specified string.
func NotRegex ¶
func NotRegex(re *regexp.Regexp) LeafConstraint
NotRegex returns a constraint that an attribute does not match the specified regex.
func Regex ¶
func Regex(re *regexp.Regexp) LeafConstraint
Regex returns a constraint that an attribute matches the specified regex.
type LeafNodeConstraint ¶
type LeafNodeConstraint interface { NodeConstraint // contains filtered or unexported methods }
LeafNodeConstraint is a leaf constraint on a Node.
func NotSameAsNode ¶
func NotSameAsNode(n *AbstractNode) LeafNodeConstraint
NotSameAsNode returns a constraint that an attribute has a different value from the specified Node.
func SameAsNode ¶
func SameAsNode(n *AbstractNode) LeafNodeConstraint
SameAsNode returns a constraint that an attribute has the same value as the specified Node.
type LeafPortConstraint ¶
type LeafPortConstraint interface { PortConstraint // contains filtered or unexported methods }
LeafPortConstraint is a leaf constraint on a Port.
func NotSameAsPort ¶
func NotSameAsPort(p *AbstractPort) LeafPortConstraint
NotSameAsPort returns a constraint that an attribute has a different value from the specified Port.
func SameAsPort ¶
func SameAsPort(p *AbstractPort) LeafPortConstraint
SameAsPort returns a constraint that an attribute has the same value as the specified Port.
type NodeConstraint ¶
type NodeConstraint interface {
// contains filtered or unexported methods
}
NodeConstraint is a constraint on a Node.
func AndNode ¶
func AndNode(nlcs ...LeafNodeConstraint) NodeConstraint
AndNode returns a constraint that contains other node constraints. An and constraint is a leaf constraint that cannot contain other leaves.
type PortConstraint ¶
type PortConstraint interface {
// contains filtered or unexported methods
}
PortConstraint is a constraint on a Port.
func AndPort ¶
func AndPort(plcs ...LeafPortConstraint) PortConstraint
AndPort returns a constraint that contains other port constraints. An and constraint is a leaf constraint that cannot contain other leaves.