graphalgo

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package graphalgo implements different algorithms for working with graph.Graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindArticulationPoints added in v0.2.1

func FindArticulationPoints[T any](g *graph.Graph[T]) []int

FindArticulationPoints finds all articulation points in given graph.

func FindCycle

func FindCycle[T any](g *graph.Graph[T]) []int

FindCycle returns cycle if there is any otherwise empty slice returned.

func FindShortestPath

func FindShortestPath[T any](g *graph.Graph[T], start, end int) []int

FindShortestPath returns vertices that shortest path contains returns nil if start == end or if there are no path.

func TopologicalSort

func TopologicalSort[T any](g *graph.Graph[T]) []int

TopologicalSort returns vertices in topological order.

func Transpose added in v0.2.1

func Transpose[T any](g *graph.Graph[T]) *graph.Graph[T]

Transpose return graph that is transposes of given graph. Returns given graph if it is not directed.

Types

type Edge added in v0.2.0

type Edge[T any] struct {
	From, To int
	Value    T
}

Edge struct represents edge of graph.

func FindBridges added in v0.2.0

func FindBridges[T any](g *graph.Graph[T]) []Edge[T]

FindBridges returns all bridges of given graph.

func KruskalMST added in v0.2.0

func KruskalMST[T constraints.Integer](g *graph.Graph[T]) []Edge[T]

KruskalMST finds minimum spanning tree using Kruskal’s algorithm.

type LCA added in v0.2.0

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

func NewLCA added in v0.2.0

func NewLCA[T any](g *graph.Graph[T]) LCA

NewLCA returns new LCA struct for computing LCA of given vertexes.

func (LCA) LCA added in v0.2.0

func (a LCA) LCA(u, v int) int

LCA returns LCA of given vertexes.

Jump to

Keyboard shortcuts

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