graph

package
v0.0.0-...-21d01d2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	// Vertices describes all vertices contained in the graph
	// The key will be the ID value of the connected vertice
	// with the value being the pointer to it
	Vertices map[string]*Vertex
}

func NewGraph

func NewGraph() *Graph

NewGraph is the constructor of Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(id1, id2 string) error

The AddEdge method adds an edge between two vertices in the graph

func (*Graph) AddVertex

func (g *Graph) AddVertex(id string, value interface{}) error

AddVertex creates a new vertex with the given key and adds it to the graph

func (*Graph) BFS

func (g *Graph) BFS(startVertexID string, visitCb func(interface{}))

func (*Graph) String

func (g *Graph) String() string

type Vertex

type Vertex struct {
	// ID is the unique identifier of the vertex
	ID string

	// Value contains a vertex's value.
	Value interface{}

	// Vertices will describe vertices connected to this one
	// The key will be the Key value of the connected vertice
	// with the value being the pointer to it
	Vertices map[interface{}]*Vertex
}

Vertex represents graph's vertex

func NewVertex

func NewVertex(id string, value interface{}) *Vertex

NewVertex is the constructor of Vertex

func (*Vertex) String

func (v *Vertex) String() string

Jump to

Keyboard shortcuts

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