graphs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Giant

func Giant[V comparable](g gograph.Graph[V]) (gograph.Graph[V], error)

Giant returns the giant component of the graph. The giant component is the largest connected component of the graph. If the graph is directed, it returns the largest strongly connected component.

func Invert

func Invert[V comparable](graph gograph.Graph[V]) gograph.Graph[V]

Invert inverts the direction of the edges in the graph.

func InvertWeight added in v0.1.0

func InvertWeight[V comparable](graph gograph.Graph[V]) gograph.Graph[V]

InvertWeight returns a new graph with the same vertices and edges as the original graph, but with the weights inverted using an exponential kernel function.

func Keep

func Keep[V comparable](g gograph.Graph[V], toKeep []V) (gograph.Graph[V], error)

Keep returns a graph with only the provided vertices and their connecting edges.

func MST

func MST[K comparable](graph gograph.Graph[K]) (gograph.Graph[K], *union.UnionFind[K])

MST returns the minimum spanning tree of the given graph.

func Mimic

func Mimic[K comparable](g gograph.Graph[K], overrideOptions ...gograph.GraphOptionFunc) gograph.Graph[K]

Mimic returns a new graph with the same properties as the original graph.

func Purge

func Purge[V comparable](g gograph.Graph[V], toRemove []V) (gograph.Graph[V], error)

Purge removes the provided vertices from the graph.

func RemoveCycles

func RemoveCycles[V comparable](g gograph.Graph[V]) (gograph.Graph[V], error)

RemoveCycles returns a graph with its cycles removed. The returned graph is a DAG.

func RemoveDangling

func RemoveDangling[V comparable](g gograph.Graph[V]) (gograph.Graph[V], error)

RemoveDangling returns a new graph with no dangling vertices

func ReverseTopologicalOrder

func ReverseTopologicalOrder[V comparable](
	graph gograph.Graph[V],
) ([]*gograph.Vertex[V], error)

ReverseTopologicalOrder returns the reverse topological order of the graph.

func TopologicalOrder

func TopologicalOrder[V comparable](
	graph gograph.Graph[V],
) ([]*gograph.Vertex[V], error)

TopologicalOrder returns the topological order of the graph.

func Undirected

func Undirected[V comparable](g gograph.Graph[V]) (gograph.Graph[V], error)

Undirected returns a new graph with the same vertices and edges as the original graph, but with all edges undirected.

func WeaklyConnectedComponents

func WeaklyConnectedComponents[T comparable](g gograph.Graph[T]) ([][]*gograph.Vertex[T], error)

WeaklyConnectedComponents returns the weakly connected components of the graph.

Types

This section is empty.

Jump to

Keyboard shortcuts

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