-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvertex_alternatives.go
More file actions
32 lines (27 loc) · 871 Bytes
/
vertex_alternatives.go
File metadata and controls
32 lines (27 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ch
type VertexAlternative struct {
Label int64
AdditionalDistance float64
}
type vertexAlternativeInternal struct {
vertexNum int64
additionalDistance float64
}
const vertexNotFound = -1
func (graph *Graph) vertexAlternativeToInternal(alternative VertexAlternative) vertexAlternativeInternal {
vertexNum, ok := graph.mapping[alternative.Label]
if !ok {
vertexNum = vertexNotFound
}
return vertexAlternativeInternal{
vertexNum: vertexNum,
additionalDistance: alternative.AdditionalDistance,
}
}
func (graph *Graph) vertexAlternativesToInternal(alternatives []VertexAlternative) []vertexAlternativeInternal {
result := make([]vertexAlternativeInternal, 0, len(alternatives))
for _, alternative := range alternatives {
result = append(result, graph.vertexAlternativeToInternal(alternative))
}
return result
}