graph

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 5 Imported by: 0

README

graph

graph

TODO

  • Extract Shortest -> Dijkstra shortest func taking graph + other
  • Extract Simplify to func taking graph returning graph
  • TEST

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DijkstraShortest

func DijkstraShortest(g Graph, from, to int) (int, []int, map[int]*VertexInfo)

func RemoveEdge

func RemoveEdge(v *Vertex, edge int)

func Simplify

func Simplify(g Graph)

Types

type DLList added in v1.0.1

type DLList struct {
	*list.List
}

func (*DLList) InsertOrdered added in v1.0.1

func (l *DLList) InsertOrdered(v *VertexInfo)

func (*DLList) PopFront added in v1.0.1

func (l *DLList) PopFront() *VertexInfo

type Graph

type Graph map[int]*Vertex

func New

func New() Graph

func (*Graph) AddBiEdge

func (g *Graph) AddBiEdge(from, to, cost int)

func (Graph) AddEdge

func (g Graph) AddEdge(from, to, cost int)

func (Graph) String

func (g Graph) String() string

type Vertex

type Vertex struct {
	Neighbours map[int]int
	Order      []int
}

func NewVertex

func NewVertex() *Vertex

func (*Vertex) AddEdge

func (v *Vertex) AddEdge(to, cost int)

func (*Vertex) Sort

func (v *Vertex) Sort()

type VertexInfo added in v1.0.1

type VertexInfo struct {
	ID       int
	Distance int
	Path     []int
}

Jump to

Keyboard shortcuts

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