graph

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PARSE_NODE_COUNT = iota
	PARSE_EDGE_COUNT = iota
	PARSE_NODES      = iota
	PARSE_EDGES      = iota
)

fmi parse states

Variables

This section is empty.

Functions

func Dijkstra

func Dijkstra(g Graph, origin, destination int) ([]int, int)

func WriteFmi

func WriteFmi(g Graph, filename string)

Types

type AdjacencyArrayGraph

type AdjacencyArrayGraph struct {
	Nodes   []Node
	Edges   []outgoingEdge
	Offsets []int
}

Implementation for static graphs

func NewAdjacencyArrayFromFmi

func NewAdjacencyArrayFromFmi(filename string) *AdjacencyArrayGraph

func NewAdjacencyArrayFromGraph

func NewAdjacencyArrayFromGraph(g Graph) *AdjacencyArrayGraph

func (*AdjacencyArrayGraph) EdgeCount

func (aag *AdjacencyArrayGraph) EdgeCount() int

func (*AdjacencyArrayGraph) GetEdgesFrom

func (aag *AdjacencyArrayGraph) GetEdgesFrom(id NodeId) []Edge

func (*AdjacencyArrayGraph) GetNode

func (aag *AdjacencyArrayGraph) GetNode(id NodeId) Node

func (*AdjacencyArrayGraph) NodeCount

func (aag *AdjacencyArrayGraph) NodeCount() int

type AdjacencyListGraph

type AdjacencyListGraph struct {
	Nodes []Node
	Edges [][]outgoingEdge
	// contains filtered or unexported fields
}

Implementation for dynamic graphs

func NewAdjacencyListFromFmi

func NewAdjacencyListFromFmi(filename string) *AdjacencyListGraph

func (*AdjacencyListGraph) AddEdge

func (alg *AdjacencyListGraph) AddEdge(e Edge)

func (*AdjacencyListGraph) AddNode

func (alg *AdjacencyListGraph) AddNode(n Node)

func (*AdjacencyListGraph) EdgeCount

func (alg *AdjacencyListGraph) EdgeCount() int

func (*AdjacencyListGraph) GetEdgesFrom

func (alg *AdjacencyListGraph) GetEdgesFrom(id NodeId) []Edge

func (*AdjacencyListGraph) GetNode

func (alg *AdjacencyListGraph) GetNode(id NodeId) Node

func (*AdjacencyListGraph) NodeCount

func (alg *AdjacencyListGraph) NodeCount() int

type DynamicGraph

type DynamicGraph interface {
	Graph
	AddNode(n Node)
	AddEdge(e Edge)
}

type Edge

type Edge struct {
	From     NodeId
	To       NodeId
	Distance int
}

func (Edge) Invert

func (e Edge) Invert() Edge

type Graph

type Graph interface {
	GetNode(id NodeId) Node
	GetEdgesFrom(id NodeId) []Edge
	NodeCount() int
	EdgeCount() int
}

type Node

type Node struct {
	Lon float64
	Lat float64
}

func NewNode

func NewNode(lon float64, lat float64) *Node

type NodeId

type NodeId = int

type PriorityQueue

type PriorityQueue []*PriorityQueueItem

A PriorityQueue implements the heap.Interface and hold PriorityQueueItems

func (PriorityQueue) Len

func (h PriorityQueue) Len() int

func (PriorityQueue) Less

func (h PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (h *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (h *PriorityQueue) Push(item interface{})

func (PriorityQueue) Swap

func (h PriorityQueue) Swap(i, j int)

type PriorityQueueItem

type PriorityQueueItem struct {
	// contains filtered or unexported fields
}

type Route

type Route struct {
	Origin      geo.Point
	Destination geo.Point
	Exists      bool        // true iff a route from origin to destination exists
	Waypoints   []geo.Point // sequence of points that describe the route
	Length      int         // length of the route
}

type ShipRouter

type ShipRouter struct {
	// contains filtered or unexported fields
}

func NewShipRouter

func NewShipRouter(g Graph) *ShipRouter

func (ShipRouter) ComputeRoute

func (sr ShipRouter) ComputeRoute(origin, destination geo.Point) (route Route)

Jump to

Keyboard shortcuts

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