github.com/hashicorp/packer@v1.14.3/internal/dag/edge.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package dag 5 6 // Edge represents an edge in the graph, with a source and target vertex. 7 type Edge interface { 8 Source() Vertex 9 Target() Vertex 10 11 Hashable 12 } 13 14 // BasicEdge returns an Edge implementation that simply tracks the source 15 // and target given as-is. 16 func BasicEdge(source, target Vertex) Edge { 17 return &basicEdge{S: source, T: target} 18 } 19 20 // basicEdge is a basic implementation of Edge that has the source and 21 // target vertex. 22 type basicEdge struct { 23 S, T Vertex 24 } 25 26 func (e *basicEdge) Hashcode() interface{} { 27 return [...]interface{}{e.S, e.T} 28 } 29 30 func (e *basicEdge) Source() Vertex { 31 return e.S 32 } 33 34 func (e *basicEdge) Target() Vertex { 35 return e.T 36 }