graph

package
v0.0.0-...-6840f52 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2015 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph interface {
	// NumVertex returns the number of vertices in the graph.
	NumVertex() int

	// VertexID returns a vertex ID, 0 <= ID < NumVertex(), for v.
	VertexID(v Vertex) int

	// Neighbors returns a slice of vertices that are adjacent
	// to v in the graph.
	Neighbors(v Vertex) []Vertex
}

A Graph is the interface implemented by graphs that this package can run algorithms on.

type Vertex

type Vertex interface {
	String() string
}

func ShortestPath

func ShortestPath(g Graph, start, end Vertex) []Vertex

ShortestPath uses Dijkstra's algorithm to find the shortest path from start to end in g. It returns the path as a slice of vertices, with start first and end last. If there is no path, ShortestPath returns nil.

Jump to

Keyboard shortcuts

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