graph

package
v0.0.0-...-0158116 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BidirectionalDijkstra

func BidirectionalDijkstra(g *Graph, from string, to string) (path string, err error)

Dijkstra算法

func ShortestPath

func ShortestPath(g *Graph, from string, to string, method ShortestPathMethod) (path string, err error)

Types

type Graph

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

func NewGraph

func NewGraph() *Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(from string, to string, weight int)

func (*Graph) AddVertex

func (g *Graph) AddVertex(id string)

func (*Graph) GetVertex

func (g *Graph) GetVertex(id string) *Vertex

type Node

type Node struct {
	ID   uint
	Next *Node
}

type ShortestPathMethod

type ShortestPathMethod string
const (
	Dijkstra ShortestPathMethod = "dijkstra"
)

type Vertex

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

func NewVertex

func NewVertex(id string) *Vertex

func (*Vertex) AddAdj

func (v *Vertex) AddAdj(adj *Vertex, weight int)

func (*Vertex) ID

func (v *Vertex) ID() string

func (*Vertex) Weight

func (v *Vertex) Weight(adj *Vertex) (weight int)

Jump to

Keyboard shortcuts

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