graph

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnWeighted = "UnWeighted"

	Directed = "Directed"

	ACyclic = "ACyclic"

	NonNegativeWeights = "NonNegativeWeights"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph[T any] interface {
	AddNode(n *Node[T])

	CreateDiEdge(curr *Node[T], next *Node[T]) error

	CreateWeightedDiEdge(curr, next *Node[T], weight int64) error

	CreateBiEdge(curr *Node[T], next *Node[T]) error

	CreateWeightedBiEdge(curr, nodes *Node[T], weight int64) error

	DeleteNode(n *Node[T]) error

	DeleteEdge(start, end *Node[T]) error

	Contains(n *Node[T]) bool

	//print()
	DFSIterator() iterator.Iterator[*Node[T]]
	BFSIterator() iterator.Iterator[*Node[T]]

	HasLoop() bool
	HasCycle() bool

	AreAdjacent(a, b *Node[T]) (bool, error)

	InDegreeOfNode(a *Node[T]) (int64, error)
	OutDegreeOfNode(a *Node[T]) (int64, error)

	Reverse()
	Clone() Graph[T]

	HasRoute(source, target *Node[T]) (bool, error)

	GetConnectedComponents() []list.List[*Node[T]]

	ShortestPath(source, target *Node[T], properties ...Property) (list.List[*Node[T]], error)
}

func NewListGraph

func NewListGraph[T any]() Graph[T]

type Node

type Node[T any] struct {
	// contains filtered or unexported fields
}

func NewNode

func NewNode[T any](data T) *Node[T]

type Property added in v0.0.3

type Property string

Jump to

Keyboard shortcuts

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