LdDl / ch

Contraction Hierarchies (with bidirectional version of Dijkstra's algorithm) technique for computing shortest path in graph.
Apache License 2.0
47 stars 5 forks source link

Refactor incident edges #17

Closed LdDl closed 3 years ago

LdDl commented 3 years ago

Vertex struct contains 4 fields currently. They are:

inEdges  []int64
inECost  []float64
outEdges []int64
outECost []float64

I think such code has not good readability, so I prepared more readable code, but with same meaning/perfomance/number of allocations:

inIncidentEdges  []incidentEdge
outIncidentEdges []incidentEdge

, where incidentEdge is:

// incidentEdge incident edge to correspondence
type incidentEdge struct {
    vertexID int64 // <---- This is replacement for INT64 in inEdges/outEdges 
    cost     float64 // <---- This is replacement for FLOAT64in inECost/outECost 
}