dijkstra

package
v0.0.0-...-09d313d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2016 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SPTree

type SPTree []*Vertex

SPTree represents the shortest path tree

func Find

func Find(g *graph.Graph, source int) SPTree

Find builds the shortest path tree using Dijkstra algorithm. A greedy algorithm that gradually builds the shortest path tree

The runtime is O((|V|+|E|)*log|E|) where |V|log|E| accounts for heap.Fix whenever we check an out-going edge. And |E|log|E| accounts for heap.Pop to get the smallest cost vertex.

func (SPTree) Path

func (t SPTree) Path(toVertex int) SPTree

Path returns the shortest path from the source vertex to a chosen vertex

func (SPTree) String

func (t SPTree) String() string

type Vertex

type Vertex struct {
	ID     int /* The id of this node */
	Parent int /* The ID of the parent vertex, -1 for the source */
	TotalC int /* The total cost from source node */
}

Vertex represents the non-visited vertex which is stored in the minimum cost priority heap

Jump to

Keyboard shortcuts

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