gograph

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-graph

A golang library for graph operations

example workflow

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEdgeExists = errors.New("edge exists between given vertices")
)
View Source
var (
	ErrIncompatibleRoutes = errors.New("routes incompatible for concatenation")
)

Functions

This section is empty.

Types

type Connections

type Connections[K comparable, W comparable, V any] map[K]WeightedEdge[W, V]

func (*Connections[K, W, V]) Added

func (s *Connections[K, W, V]) Added(item K, weight W, edge V) *Connections[K, W, V]

func (*Connections[K, W, V]) Exists

func (s *Connections[K, W, V]) Exists(item K) bool

type Graph

type Graph[K comparable, V any] struct {
	IsBidirectional      bool                            `json:"IsBidrectional"`
	Vertices             map[K]Connections[K, uint64, V] `json:"Vertices"`
	VertexCount          int                             `json:"VertexCount"`
	EdgeCount            int                             `json:"EdgeCount"`
	AllPairShortestPaths map[Tuple2[K]]Route[K, V]       `json:"AllPairShortestPath"`
}

func NewGraphStringUintString

func NewGraphStringUintString(bidirectional bool) *Graph[string, string]

func (*Graph[K, V]) AddEdge

func (g *Graph[K, V]) AddEdge(from K, to K, weight uint64, edge V) error

func (*Graph[K, V]) CalculateAllPairShortestPath

func (g *Graph[K, V]) CalculateAllPairShortestPath()

func (*Graph[K, V]) GetConnectedVertices

func (g *Graph[K, V]) GetConnectedVertices(vertex K) Connections[K, uint64, V]

func (*Graph[K, V]) GetEdgeCount

func (g *Graph[K, V]) GetEdgeCount() int

func (*Graph[K, V]) GetShortestRoute

func (g *Graph[K, V]) GetShortestRoute(from K, to K) Route[K, V]

func (*Graph[K, V]) GetVertexCount

func (g *Graph[K, V]) GetVertexCount() int

func (*Graph[K, V]) ReadFromDisk

func (g *Graph[K, V]) ReadFromDisk(fileLocation string) error

func (*Graph[K, V]) SaveToDisk

func (g *Graph[K, V]) SaveToDisk(fileLocation string) error

type Route

type Route[K comparable, V any] struct {
	Vertices []K
	Edges    []WeightedEdge[uint64, V]
	Distance uint64
}

func (*Route[K, V]) AppendRoute

func (r *Route[K, V]) AppendRoute(second *Route[K, V]) error

type Tuple2

type Tuple2[K comparable] struct {
	One K
	Two K
}

type WeightedEdge

type WeightedEdge[W comparable, V any] struct {
	Weight   W
	Metadata V
}

Jump to

Keyboard shortcuts

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