vertexes

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vertex

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

Vertex implements a graph Vertex

func NewVertex

func NewVertex(name string, value int) *Vertex

NewVertex returns a new Vertex

func (*Vertex) AddNeighbor

func (v *Vertex) AddNeighbor(vertex *Vertex)

AddNeighbor adds a neighbor vertex

func (*Vertex) Decrement

func (v *Vertex) Decrement()

Decrement decrements the vertex value by 1

func (*Vertex) Degree

func (v *Vertex) Degree() int

Degree returns the degree of the incoming edges (loops count as 2)

func (*Vertex) Equal

func (v *Vertex) Equal(vertex Vertex) bool

Equal returns true if v and vertex represent the same vertex

func (*Vertex) FirstNeighbor

func (v *Vertex) FirstNeighbor() *Vertex

FirstNeighbor returns the first neighbor

func (*Vertex) HasNeighbor

func (v *Vertex) HasNeighbor(vertex Vertex) bool

HasNeighbor returns true if the given vertex is already a neighbor

func (*Vertex) ID

func (v *Vertex) ID() uint64

ID returns the id of the vertex

func (*Vertex) Increment

func (v *Vertex) Increment()

Increment increments the vertex value by 1

func (*Vertex) Label

func (v *Vertex) Label() string

Label returns a label for the given vertex

func (*Vertex) Name

func (v *Vertex) Name() string

Name returns the vertex name

func (*Vertex) NeighborCount

func (v *Vertex) NeighborCount() int

NeighborCount returns the number of edges (neighbors)

func (*Vertex) Neighbors

func (v *Vertex) Neighbors() []*Vertex

Neighbors returns a slice of all neighbors

func (*Vertex) RemoveNeighbor

func (v *Vertex) RemoveNeighbor(vertex Vertex)

RemoveNeighbor removes a neighbor vertex

func (*Vertex) SetID

func (v *Vertex) SetID(id uint64)

SetID sets the id of the vertex (use with extreme caution)

func (*Vertex) SetName

func (v *Vertex) SetName(name string)

SetName sets the vertex name

func (*Vertex) SetValue

func (v *Vertex) SetValue(value int)

SetValue sets the vertex value

func (*Vertex) SortNeighbors

func (v *Vertex) SortNeighbors()

SortNeighbors returns a sorted slice of all neighbors

func (*Vertex) Value

func (v *Vertex) Value() int

Value returns the vertex value

Jump to

Keyboard shortcuts

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