terraform/internal/dag/edge.go

34 lines
664 B
Go
Raw Normal View History

2015-01-24 00:01:58 +01:00
package dag
// Edge represents an edge in the graph, with a source and target vertex.
type Edge interface {
Source() Vertex
Target() Vertex
2015-02-13 23:12:23 +01:00
Hashable
2015-01-24 00:01:58 +01:00
}
// BasicEdge returns an Edge implementation that simply tracks the source
// and target given as-is.
func BasicEdge(source, target Vertex) Edge {
return &basicEdge{S: source, T: target}
}
// basicEdge is a basic implementation of Edge that has the source and
// target vertex.
type basicEdge struct {
S, T Vertex
}
func (e *basicEdge) Hashcode() interface{} {
return [...]interface{}{e.S, e.T}
}
2015-01-24 00:01:58 +01:00
func (e *basicEdge) Source() Vertex {
return e.S
}
func (e *basicEdge) Target() Vertex {
return e.T
}