ewgraph

package
v0.0.0-...-118f76d Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllGraphWeights

func AllGraphWeights(wgr EdgeWeightedGraph) []float64

AllGraphWeights returns all edge weights of an edge-weighted graph.

func TotalGraphWeight

func TotalGraphWeight(wgr EdgeWeightedGraph) float64

TotalGraphWeight returns total weight of a grapgrh.

Types

type EdgeWeightedGraph

type EdgeWeightedGraph interface {
	graph.Graph
	// AdjacentWeights returns weights of edges adjacent to the vertex.
	AdjacentWeights(vertexID int) []float64
}

EdgeWeightedGraph is a graph where each edge has an associated weight.

func BuildMinimumSpanningTreeKruskal

func BuildMinimumSpanningTreeKruskal(wgr EdgeWeightedGraph) EdgeWeightedGraph

BuildMinimumSpanningTreeKruskal computes minimum spanning tree using Kruskal's algorithm. https://algs4.cs.princeton.edu/43mst/KruskalMST.java.html

func BuildMinimumSpanningTreePrim

func BuildMinimumSpanningTreePrim(wgr EdgeWeightedGraph) EdgeWeightedGraph

BuildMinimumSpanningTreePrim computes minimum spanning tree using Prim's algorithm. https://algs4.cs.princeton.edu/43mst/PrimMST.java.html

type ImplEdgeWeightedGraph

type ImplEdgeWeightedGraph struct {
	graph.Graph
	// contains filtered or unexported fields
}

ImplEdgeWeightedGraph is an implementaion of EdgeWeightedGraph.

func NewImplEdgeWeightedGraph

func NewImplEdgeWeightedGraph(
	numVertices int, numEdges int, adjacency [][]int, weights [][]float64,
) *ImplEdgeWeightedGraph

NewImplEdgeWeightedGraph creates instance of EdgeWeightedGraph.

func (*ImplEdgeWeightedGraph) AdjacentWeights

func (wgr *ImplEdgeWeightedGraph) AdjacentWeights(vertexID int) []float64

AdjacentWeights returns weights of edges adjacent to the vertex.

Jump to

Keyboard shortcuts

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