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

Freeze graph [FEATURE REQUEST] #4

Closed LdDl closed 4 years ago

LdDl commented 4 years ago

Is your feature request related to a problem? Please describe. When preprocessing is done need to prevent graph from any kind of data modification. So users/developers won't make mistake trying to insert vertices to graph after it had been contracted.

Describe the solution you'd like and provide pseudocode examples if you can go-ish pseudocode:

type Graph struct {
    frozen bool
}
func (g *Graph) ModifyData(....) error {
    if g.frozen {
        return "can't modify data in frozen graph"
    }
}
func (g *Graph) PrepareContracts() error {
    {
    // graph preparation
    }
    g.Freeze()
}
// Freeze - Exported
func (g *Graph) Freeze() {
    g.frozen = true
}
// unfreeze - unexported
func (g *Graph) unfreeze() {
    g.frozen = false
}

Describe alternatives you've considered and provide pseudocode examples if you can nope

Additional context nope

LdDl commented 4 years ago

Thanks to @Pavel7824