Version: v1.0.52 Latest Latest

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

Go to latest
Published: Mar 9, 2020 License: Apache-2.0 Imports: 2 Imported by: 0



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



This section is empty.


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")


This section is empty.


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:

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL