dijkstra

package
v0.0.0-...-950f727 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2014 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package Dijkstra provides an implementation of Dijkstra Algorithm to find the shortest path in directed graph.

The Dijkstra Algorithm traverses a graph object implementing the dijkstrastruct.GraphObject interface to find the shortest path; the only limitation is that all the edges' weights must be non-negative. The returned path, an instance of DijkstraPath struct, is a loopless path going from the starting node to the destination; it can be computed using either the "vanilla" Dijkstra algorithm or a bidirectional search algorithm.

Index

Constants

View Source
const (
	VANILLA = iota // Use "vanilla" Dijkstra algorithm
	BIDIR          // Use bi-directional search algorithm
)

Variables

This section is empty.

Functions

func BiDirDijkstra

func BiDirDijkstra(graph dijkstrastructs.GraphObject, startNode, endNode string, bannedEdges dijkstrastructs.UnusableEdgeMap) (dijkstrapath.DijkstraPath, bool)

func Dijkstra

func Dijkstra(graph dijkstrastructs.GraphObject, startNode, endNode string, bannedEdges dijkstrastructs.UnusableEdgeMap) (dijkstrapath.DijkstraPath, bool)

func SearchPath

func SearchPath(graph dijkstrastructs.GraphObject, startNode, endNode string, searchType int) (dijkstrapath.DijkstraPath, bool)

Dijkstra returns the shortest path within the provided graph object that goes from startNode to endNode nodes. searchType parameter defines the type of algorithm to use.

Types

type DijkstraQueue

type DijkstraQueue []*dijkstrastructs.DijkstraCandidate

DijkstraQueue is a collecition of DijkstraCandidate elements. It implements the heap.Interface interface to be used as a heap.

func (DijkstraQueue) Len

func (pq DijkstraQueue) Len() int

func (DijkstraQueue) Less

func (pq DijkstraQueue) Less(i, j int) bool

func (*DijkstraQueue) Pop

func (pq *DijkstraQueue) Pop() interface{}

func (*DijkstraQueue) Push

func (pq *DijkstraQueue) Push(x interface{})

func (DijkstraQueue) Swap

func (pq DijkstraQueue) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL