mirror of
https://github.com/hashicorp/terraform.git
synced 2026-03-27 12:54:12 -04:00
36 lines
736 B
Go
36 lines
736 B
Go
// Copyright IBM Corp. 2014, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package dag
|
|
|
|
// Edge represents an edge in the graph, with a source and target vertex.
|
|
type Edge interface {
|
|
Source() Vertex
|
|
Target() Vertex
|
|
|
|
Hashable
|
|
}
|
|
|
|
// 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}
|
|
}
|
|
|
|
func (e *basicEdge) Source() Vertex {
|
|
return e.S
|
|
}
|
|
|
|
func (e *basicEdge) Target() Vertex {
|
|
return e.T
|
|
}
|