Documentation ¶
Index ¶
- func ConvertToNodeOrdering(nodeOrderingString string) [][]int
- func ReadNodeOrderingFile(filename string) [][]int
- type BidirectionalConnection
- type ContractionHierarchies
- func (ch *ContractionHierarchies) ComputeShortestPath(origin, destination graph.NodeId) int
- func (ch *ContractionHierarchies) GetEdgeRelaxations() int
- func (ch *ContractionHierarchies) GetGraph() graph.Graph
- func (ch *ContractionHierarchies) GetPath(origin, destination graph.NodeId) []int
- func (ch *ContractionHierarchies) GetPqPops() int
- func (ch *ContractionHierarchies) GetPqUpdates() int
- func (ch *ContractionHierarchies) GetRelaxationAttempts() int
- func (ch *ContractionHierarchies) GetSearchSpace() []*DijkstraItem
- func (ch *ContractionHierarchies) GetShortcuts() []Shortcut
- func (ch *ContractionHierarchies) GetStalledNodesCount() int
- func (ch *ContractionHierarchies) GetUnstalledNodesCount() int
- func (ch *ContractionHierarchies) Precompute(givenNodeOrder []int, oo OrderOptions)
- func (ch *ContractionHierarchies) SetDebugLevel(level int)
- func (ch *ContractionHierarchies) SetNodeOrdering(nodeOrdering [][]int)
- func (ch *ContractionHierarchies) SetPrecomputationMilestones(milestones []float64)
- func (ch *ContractionHierarchies) SetShortcuts(shortcuts []Shortcut)
- func (ch *ContractionHierarchies) SetSortArcs(sort bool)
- func (ch *ContractionHierarchies) ShortestPathSetup(options PathFindingOptions)
- func (ch *ContractionHierarchies) WriteContractionResult()
- func (ch *ContractionHierarchies) WriteGraph()
- func (ch *ContractionHierarchies) WriteNodeOrdering()
- func (ch *ContractionHierarchies) WriteShortcuts()
- type ContractionOptions
- type ContractionProgress
- type ContractionResult
- type Dijkstra
- func (d *Dijkstra) ComputeShortestPath(origin, destination int) int
- func (d *Dijkstra) GetEdgeRelaxations() int
- func (d *Dijkstra) GetGraph() graph.Graph
- func (d *Dijkstra) GetPath(origin, destination graph.NodeId) []graph.NodeId
- func (d *Dijkstra) GetPqPops() int
- func (d *Dijkstra) GetPqUpdates() int
- func (d *Dijkstra) GetRelaxationAttempts() int
- func (d *Dijkstra) GetSearchSpace() []*DijkstraItem
- func (d *Dijkstra) GetStalledNodesCount() int
- func (d *Dijkstra) GetUnstalledNodesCount() int
- type DijkstraItem
- type Direction
- type Milestone
- type Navigator
- type OrderItem
- type OrderOptions
- func (oo OrderOptions) ConsiderEdgeDifference() bool
- func (oo OrderOptions) ConsiderProcessedNeighbors() bool
- func (oo OrderOptions) IsLazyUpdate() bool
- func (oo OrderOptions) IsPeriodic() bool
- func (oo OrderOptions) IsRandom() bool
- func (oo OrderOptions) IsValid() bool
- func (oo OrderOptions) Reset(o OrderOptions) OrderOptions
- func (oo OrderOptions) Set(o OrderOptions) OrderOptions
- func (oo OrderOptions) SetEdgeDifference(flag bool) OrderOptions
- func (oo OrderOptions) SetLazyUpdate(flag bool) OrderOptions
- func (oo OrderOptions) SetPeriodic(flag bool) OrderOptions
- func (oo OrderOptions) SetProcessedNeighbors(flag bool) OrderOptions
- func (oo OrderOptions) SetRandom(flag bool) OrderOptions
- func (oo OrderOptions) SetUpdateNeighbors(flag bool) OrderOptions
- func (oo OrderOptions) UpdateNeighbors() bool
- type PathFindingOptions
- type SearchKPIs
- type SearchOptions
- type SearchStats
- type Shortcut
- type UniversalDijkstra
- func (d *UniversalDijkstra) ComputeShortestPath(origin, destination graph.NodeId) int
- func (d *UniversalDijkstra) GetEdgeRelaxations() int
- func (d *UniversalDijkstra) GetGraph() graph.Graph
- func (d *UniversalDijkstra) GetPath(origin, destination int) []int
- func (d *UniversalDijkstra) GetPqPops() int
- func (d *UniversalDijkstra) GetPqUpdates() int
- func (d *UniversalDijkstra) GetRelaxationAttempts() int
- func (d *UniversalDijkstra) GetSearchSpace() []*DijkstraItem
- func (d *UniversalDijkstra) GetStalledNodesCount() int
- func (d *UniversalDijkstra) GetUnstalledNodesCount() int
- func (d *UniversalDijkstra) SetBidirectional(bidirectional bool)
- func (d *UniversalDijkstra) SetConsiderArcFlags(considerArcFlags bool)
- func (d *UniversalDijkstra) SetCostUpperBound(costUpperBound int)
- func (d *UniversalDijkstra) SetDebugLevel(level int)
- func (d *UniversalDijkstra) SetHotStart(useHotStart bool)
- func (d *UniversalDijkstra) SetIgnoreNodes(nodes []bool)
- func (d *UniversalDijkstra) SetMaxNumSettledNodes(maxNumSettledNodes int)
- func (d *UniversalDijkstra) SetStallOnDemand(level int)
- func (d *UniversalDijkstra) SetUseHeuristic(useHeuristic bool)
- func (d *UniversalDijkstra) SortedArcs(sorted bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToNodeOrdering ¶
Parse a string to a lsit which specifies the node order
func ReadNodeOrderingFile ¶
Read a node ordering file and return the node order
Types ¶
type BidirectionalConnection ¶
type BidirectionalConnection struct {
// contains filtered or unexported fields
}
Describes the connection of a bidirectional search
func (*BidirectionalConnection) Reset ¶
func (con *BidirectionalConnection) Reset()
Reset/invalidate the connection
type ContractionHierarchies ¶
type ContractionHierarchies struct {
// contains filtered or unexported fields
}
Provides the precomputation and query for shortest paths with the use of Contraction Hierarchies. Implements the Navigator Interface.
func NewContractionHierarchies ¶
func NewContractionHierarchies(g graph.Graph, dijkstra *UniversalDijkstra, options ContractionOptions) *ContractionHierarchies
Create a new Contraction Hierarchy. Before a query can get executed, the Precomputation has to be done
func NewContractionHierarchiesInitialized ¶
func NewContractionHierarchiesInitialized(g graph.Graph, dijkstra *UniversalDijkstra, shortcuts []Shortcut, nodeOrdering [][]int, pathFindingOptions PathFindingOptions) *ContractionHierarchies
Create a new Contraction Hierarchy which is already initialized with the shortcuts and node ordering. This can directly start a new query
func (*ContractionHierarchies) ComputeShortestPath ¶
func (ch *ContractionHierarchies) ComputeShortestPath(origin, destination graph.NodeId) int
Compute the shortest path for the given query (from origin to destination node). It returns the length of the path. If no path was found, -1 is returned
func (*ContractionHierarchies) GetEdgeRelaxations ¶
func (ch *ContractionHierarchies) GetEdgeRelaxations() int
Get the number of relaxed edges
func (*ContractionHierarchies) GetGraph ¶
func (ch *ContractionHierarchies) GetGraph() graph.Graph
get the used graph
func (*ContractionHierarchies) GetPath ¶
func (ch *ContractionHierarchies) GetPath(origin, destination graph.NodeId) []int
Get the computed path. A slice is returned which contains the node IDs in order from source to target
func (*ContractionHierarchies) GetPqPops ¶
func (ch *ContractionHierarchies) GetPqPops() int
Get the number of pq pops (from the priority queue)
func (*ContractionHierarchies) GetPqUpdates ¶
func (ch *ContractionHierarchies) GetPqUpdates() int
Get the number of the pq updates
func (*ContractionHierarchies) GetRelaxationAttempts ¶
func (ch *ContractionHierarchies) GetRelaxationAttempts() int
Get the number for how many edges the relaxation was tested (but maybe early terminated)
func (*ContractionHierarchies) GetSearchSpace ¶
func (ch *ContractionHierarchies) GetSearchSpace() []*DijkstraItem
Get the search space of the path finding query S slice is returned which contains all settled nodes of the query (containing the search information, e.g. distance to source node, which search direction was used for this item, ...)
func (*ContractionHierarchies) GetShortcuts ¶
func (ch *ContractionHierarchies) GetShortcuts() []Shortcut
Get the calculated shortcuts.
func (*ContractionHierarchies) GetStalledNodesCount ¶
func (ch *ContractionHierarchies) GetStalledNodesCount() int
Get the number of stalled nodes (invocations)
func (*ContractionHierarchies) GetUnstalledNodesCount ¶
func (ch *ContractionHierarchies) GetUnstalledNodesCount() int
Get the number of unstalled nodes (invocations)
func (*ContractionHierarchies) Precompute ¶
func (ch *ContractionHierarchies) Precompute(givenNodeOrder []int, oo OrderOptions)
Do the precomputation of the Contraction Hierarchies. This adds new Edges in the graph by adding shortcuts. The result will be a modified graph, a collection of shortcuts and the calculated node ordering. If givenNodeOrder is not nil, the OrderOption oo are ignored. givenNodeOrder predefines the order of the nodes. oo defines how the node ordering will be calculated.
func (*ContractionHierarchies) SetDebugLevel ¶
func (ch *ContractionHierarchies) SetDebugLevel(level int)
Set the debug level
func (*ContractionHierarchies) SetNodeOrdering ¶
func (ch *ContractionHierarchies) SetNodeOrdering(nodeOrdering [][]int)
Set the node ordering by an already available list. This is used when one has already a contracted graph and one need to define in which order the nodes were contracted. the index of the list reflects to the node id, the value to the level/position, when the node was contracted.
func (*ContractionHierarchies) SetPrecomputationMilestones ¶
func (ch *ContractionHierarchies) SetPrecomputationMilestones(milestones []float64)
Set the precomputation milestones (which are worth a log message)
func (*ContractionHierarchies) SetShortcuts ¶
func (ch *ContractionHierarchies) SetShortcuts(shortcuts []Shortcut)
Set the shortcuts by an already available list. This is used when one has already a contracted graph and one need to define which arcs are shortcuts.
func (*ContractionHierarchies) SetSortArcs ¶
func (ch *ContractionHierarchies) SetSortArcs(sort bool)
Set if the arcs should be sorted flag indicating if the arcs are sorted according if they are enabled or not (list will contain enabled arcs, then disabled arcs)
func (*ContractionHierarchies) ShortestPathSetup ¶
func (ch *ContractionHierarchies) ShortestPathSetup(options PathFindingOptions)
Setup ch to compute the shortest path
func (*ContractionHierarchies) WriteContractionResult ¶
func (ch *ContractionHierarchies) WriteContractionResult()
Write the contraciotn resutl (graph, shortcuts, node ordering) to a file
func (*ContractionHierarchies) WriteGraph ¶
func (ch *ContractionHierarchies) WriteGraph()
Write the graph to a file
func (*ContractionHierarchies) WriteNodeOrdering ¶
func (ch *ContractionHierarchies) WriteNodeOrdering()
Write the node ordering to a file
func (*ContractionHierarchies) WriteShortcuts ¶
func (ch *ContractionHierarchies) WriteShortcuts()
Write the shortcuts to a file
type ContractionOptions ¶
type ContractionOptions struct { Bidirectional bool // use bidirectional search UseHeuristic bool // use astar HotStart bool // use hot start MaxNumSettledNodes int // limit the number of settled nodes. If this is reached a shortcut is added ContractionLimit float64 // upper bound (in %) until which limit the nodes are contracted. If this is 99, only the contraction from level 0 to 99 is calculated ContractionWorkers int // set the number of contraction workers who parallely compute the contraction UseCache bool // use a cache to store already known shortcuts for uncontracted nodes }
Colleciton/Options how to contract the nodes. can be used as tuning options
func MakeDefaultContractionOptions ¶
func MakeDefaultContractionOptions() ContractionOptions
Make default contraction options
type ContractionProgress ¶
type ContractionProgress struct {
// contains filtered or unexported fields
}
Contains the contraction progress information
type ContractionResult ¶
type ContractionResult struct {
// contains filtered or unexported fields
}
Contrains the result of a (computed, virtual) node contraction
type Dijkstra ¶
type Dijkstra struct {
// contains filtered or unexported fields
}
func NewDijkstra ¶
func (*Dijkstra) ComputeShortestPath ¶
func (*Dijkstra) GetEdgeRelaxations ¶
func (*Dijkstra) GetPqUpdates ¶
func (*Dijkstra) GetRelaxationAttempts ¶
func (*Dijkstra) GetSearchSpace ¶
func (d *Dijkstra) GetSearchSpace() []*DijkstraItem
func (*Dijkstra) GetStalledNodesCount ¶
func (*Dijkstra) GetUnstalledNodesCount ¶
type DijkstraItem ¶
type DijkstraItem struct {
// contains filtered or unexported fields
}
implements queue.Priorizable
func NewDijkstraItem ¶
func (*DijkstraItem) Index ¶
func (item *DijkstraItem) Index() int
func (*DijkstraItem) NodeId ¶
func (item *DijkstraItem) NodeId() graph.NodeId
func (*DijkstraItem) Priority ¶
func (item *DijkstraItem) Priority() int
func (*DijkstraItem) SetIndex ¶
func (item *DijkstraItem) SetIndex(index int)
func (*DijkstraItem) String ¶
func (item *DijkstraItem) String() string
type Milestone ¶
type Milestone struct {
// contains filtered or unexported fields
}
Contains information for a milestone. Helpful for debugging/storing progress
type OrderItem ¶
type OrderItem struct {
// contains filtered or unexported fields
}
implement queue.Priorizable
func NewOrderItem ¶
type OrderOptions ¶
type OrderOptions byte
Provides different options how the NodeOrder can get computed
func MakeOrderOptions ¶
func MakeOrderOptions() OrderOptions
Create a new OrderOptions (which in initially empty)
func (OrderOptions) ConsiderEdgeDifference ¶
func (oo OrderOptions) ConsiderEdgeDifference() bool
func (OrderOptions) ConsiderProcessedNeighbors ¶
func (oo OrderOptions) ConsiderProcessedNeighbors() bool
func (OrderOptions) IsLazyUpdate ¶
func (oo OrderOptions) IsLazyUpdate() bool
func (OrderOptions) IsPeriodic ¶
func (oo OrderOptions) IsPeriodic() bool
func (OrderOptions) IsRandom ¶
func (oo OrderOptions) IsRandom() bool
func (OrderOptions) IsValid ¶
func (oo OrderOptions) IsValid() bool
func (OrderOptions) Reset ¶
func (oo OrderOptions) Reset(o OrderOptions) OrderOptions
Reset the defined options and return a new OrderOptions
func (OrderOptions) Set ¶
func (oo OrderOptions) Set(o OrderOptions) OrderOptions
Set the defined options and return a new OrderOptions
func (OrderOptions) SetEdgeDifference ¶
func (oo OrderOptions) SetEdgeDifference(flag bool) OrderOptions
func (OrderOptions) SetLazyUpdate ¶
func (oo OrderOptions) SetLazyUpdate(flag bool) OrderOptions
Set the dynamic option and return a new OrderOptions
func (OrderOptions) SetPeriodic ¶
func (oo OrderOptions) SetPeriodic(flag bool) OrderOptions
func (OrderOptions) SetProcessedNeighbors ¶
func (oo OrderOptions) SetProcessedNeighbors(flag bool) OrderOptions
func (OrderOptions) SetRandom ¶
func (oo OrderOptions) SetRandom(flag bool) OrderOptions
func (OrderOptions) SetUpdateNeighbors ¶
func (oo OrderOptions) SetUpdateNeighbors(flag bool) OrderOptions
func (OrderOptions) UpdateNeighbors ¶
func (oo OrderOptions) UpdateNeighbors() bool
type PathFindingOptions ¶
type PathFindingOptions struct { Manual bool // do an independent forward and backward search and check the connection manually UseHeuristic bool // TODO use astar StallOnDemand int // define the level for stall on demand (See UniversalDijkstra for more information) SortArcs bool // sort the arcs to only consider the active edges }
Collection/Options how to search for the path. Can be used as tuning parameters
func MakeDefaultPathFindingOptions ¶
func MakeDefaultPathFindingOptions() PathFindingOptions
Make default path finding options
type SearchKPIs ¶
type SearchKPIs struct {
// contains filtered or unexported fields
}
type SearchOptions ¶
type SearchOptions struct {
// contains filtered or unexported fields
}
type SearchStats ¶
type SearchStats struct {
// contains filtered or unexported fields
}
func (*SearchStats) Reset ¶
func (stats *SearchStats) Reset(size int, stallLevel int)
Reset the search stats
type Shortcut ¶
type Shortcut struct {
// contains filtered or unexported fields
}
Describes a shortcut. It contains the information of the source and target node and via which node this shortcut is spanned
func ConvertToShortcuts ¶
Parse a string to a list of shortcuts
func ReadShortcutFile ¶
Read a shortcuts file and return the list of shortcuts
type UniversalDijkstra ¶
type UniversalDijkstra struct {
// contains filtered or unexported fields
}
UniversalDijkstra implements various path finding algorithms which all are based on Dijkstra. it can be used for plain Dijsktra, Bidirectional search, A* (and maybe more will come). Implements the Navigator Interface.
func NewUniversalDijkstra ¶
func NewUniversalDijkstra(g graph.Graph) *UniversalDijkstra
Create a new Dijkstra instance with the given graph g
func (*UniversalDijkstra) ComputeShortestPath ¶
func (d *UniversalDijkstra) ComputeShortestPath(origin, destination graph.NodeId) int
Compute the shortest path from the origin to the destination. It returns the length of the found path If no path was found, it returns -1 If the path to all possible target is calculated (set target to -1), it returns 0
func (*UniversalDijkstra) GetEdgeRelaxations ¶
func (d *UniversalDijkstra) GetEdgeRelaxations() int
Get the number of relaxed edges
func (*UniversalDijkstra) GetGraph ¶
func (d *UniversalDijkstra) GetGraph() graph.Graph
Get the used graph
func (*UniversalDijkstra) GetPath ¶
func (d *UniversalDijkstra) GetPath(origin, destination int) []int
Get the path of a previous computation. This contains the nodeIds which lie on the path from source to destination
func (*UniversalDijkstra) GetPqPops ¶
func (d *UniversalDijkstra) GetPqPops() int
Returns the amount of priority queue/heap pops which werer performed during the search
func (*UniversalDijkstra) GetPqUpdates ¶
func (d *UniversalDijkstra) GetPqUpdates() int
Get the number of pq updates
func (*UniversalDijkstra) GetRelaxationAttempts ¶
func (d *UniversalDijkstra) GetRelaxationAttempts() int
Get the number of attempted edge relaxations (some may early terminated)
func (*UniversalDijkstra) GetSearchSpace ¶
func (d *UniversalDijkstra) GetSearchSpace() []*DijkstraItem
Returns the search space of a previous computation. This contains all items which were settled.
func (*UniversalDijkstra) GetStalledNodesCount ¶
func (d *UniversalDijkstra) GetStalledNodesCount() int
Get the number of stalling invocations
func (*UniversalDijkstra) GetUnstalledNodesCount ¶
func (d *UniversalDijkstra) GetUnstalledNodesCount() int
Get the number of unstall invocations
func (*UniversalDijkstra) SetBidirectional ¶
func (d *UniversalDijkstra) SetBidirectional(bidirectional bool)
Specify wheter the search should be done in both directions
func (*UniversalDijkstra) SetConsiderArcFlags ¶
func (d *UniversalDijkstra) SetConsiderArcFlags(considerArcFlags bool)
SPecify if the arc flags of the Arcs should be considered. If set to false, Arcs with a negative flag will be ignored by the path finding
func (*UniversalDijkstra) SetCostUpperBound ¶
func (d *UniversalDijkstra) SetCostUpperBound(costUpperBound int)
Set the upper cost for a valid path from source to target
func (*UniversalDijkstra) SetDebugLevel ¶
func (d *UniversalDijkstra) SetDebugLevel(level int)
Set the debug level to show different debug messages. If it is 0, no debug messages are printed
func (*UniversalDijkstra) SetHotStart ¶
func (d *UniversalDijkstra) SetHotStart(useHotStart bool)
Use a hot start
func (*UniversalDijkstra) SetIgnoreNodes ¶
func (d *UniversalDijkstra) SetIgnoreNodes(nodes []bool)
Set the nodes which are ignored in the search
func (*UniversalDijkstra) SetMaxNumSettledNodes ¶
func (d *UniversalDijkstra) SetMaxNumSettledNodes(maxNumSettledNodes int)
Set the maximum number of nodes that can get settled before the search is terminated
func (*UniversalDijkstra) SetStallOnDemand ¶
func (d *UniversalDijkstra) SetStallOnDemand(level int)
Use stall on demand
func (*UniversalDijkstra) SetUseHeuristic ¶
func (d *UniversalDijkstra) SetUseHeuristic(useHeuristic bool)
Specify whether a heuristic for path finding (AStar) should be used
func (*UniversalDijkstra) SortedArcs ¶
func (d *UniversalDijkstra) SortedArcs(sorted bool)
use sorted arcs (for early termination)