graph

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package graph provides graph implementations. Currently, this includes an undirected simple graph.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVertexNotFound is returned when an operation is requested on a
	// non-existent vertex.
	ErrVertexNotFound = errors.New("vertex not found")

	// ErrSelfLoop is returned when an operation tries to create a disallowed
	// self loop.
	ErrSelfLoop = errors.New("self loops not permitted")

	// ErrParallelEdge is returned when an operation tries to create a
	// disallowed parallel edge.
	ErrParallelEdge = errors.New("parallel edges are not permitted")
)

Functions

This section is empty.

Types

type SimpleGraph

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

SimpleGraph is a mutable, non-persistent undirected graph. Parallel edges and self-loops are not permitted. Additional description: https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)#Simple_graph

func NewSimpleGraph

func NewSimpleGraph() *SimpleGraph

NewSimpleGraph creates and returns a SimpleGraph

func (*SimpleGraph) AddEdge

func (g *SimpleGraph) AddEdge(v, w interface{}) error

AddEdge will create an edge between vertices v and w

func (*SimpleGraph) Adj

func (g *SimpleGraph) Adj(v interface{}) ([]interface{}, error)

Adj returns the list of all vertices connected to v

func (*SimpleGraph) Degree

func (g *SimpleGraph) Degree(v interface{}) (int, error)

Degree returns the number of vertices connected to v

func (*SimpleGraph) E

func (g *SimpleGraph) E() int

E returns the number of edges in the SimpleGraph

func (*SimpleGraph) V

func (g *SimpleGraph) V() int

V returns the number of vertices in the SimpleGraph

Jump to

Keyboard shortcuts

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