graph

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveGraphToJSON

func SaveGraphToJSON[Node comparable, Edge any](
	graph AbstractGraph[Node, Edge],
	filename string,
) error

func ToDotDirected

func ToDotDirected[Node comparable, Edge any](g Graph[Node, Edge]) (string, error)

func ToDotUndirected

func ToDotUndirected[Node comparable, Edge any](g Graph[Node, Edge]) (string, error)

Types

type AbstractGraph

type AbstractGraph[Node comparable, Edge any] map[Node]map[Node]Edge

func FromDGDot

func FromDGDot[Node comparable, Edge any](path string, convert func(string) Node) (AbstractGraph[Node, Edge], error)

func FromDot

func FromDot[Node comparable, Edge any](path, edgeString string, convert func(string) Node) (AbstractGraph[Node, Edge], error)

func FromUDGDot

func FromUDGDot[Node comparable, Edge any](path string, convert func(string) Node) (AbstractGraph[Node, Edge], error)

func LoadGraphFromJSON

func LoadGraphFromJSON[Node comparable, Edge any](
	filename string,
) (AbstractGraph[Node, Edge], error)

func NewAbstractGraph

func NewAbstractGraph[Node comparable, Edge any]() AbstractGraph[Node, Edge]

func (AbstractGraph[Node, Edge]) AddBothEdges

func (g AbstractGraph[Node, Edge]) AddBothEdges(a, b Node, edge Edge)

func (AbstractGraph[Node, Edge]) AddEdge

func (g AbstractGraph[Node, Edge]) AddEdge(a, b Node, edge Edge)

func (AbstractGraph[Node, Edge]) AllNodes

func (g AbstractGraph[Node, Edge]) AllNodes() []Node

func (AbstractGraph[Node, Edge]) EdgesNeighbors

func (g AbstractGraph[Node, Edge]) EdgesNeighbors(a Node) ([]Edge, []Node)

type DGraph

type DGraph[Node comparable, Edge any] AbstractGraph[Node, Edge]

func NewDGraph

func NewDGraph[Node comparable, Edge any]() DGraph[Node, Edge]

func (DGraph[Node, Edge]) AddBothEdges

func (g DGraph[Node, Edge]) AddBothEdges(a, b Node, edge Edge)

func (DGraph[Node, Edge]) AddEdge

func (g DGraph[Node, Edge]) AddEdge(a, b Node, edge Edge)

func (DGraph[Node, Edge]) AllNodes

func (g DGraph[Node, Edge]) AllNodes() []Node

func (DGraph[Node, Edge]) EdgesNeighbors

func (g DGraph[Node, Edge]) EdgesNeighbors(a Node) ([]Edge, []Node)

type Graph

type Graph[Node comparable, Edge any] interface {
	AddEdge(a, b Node, e Edge)
	AddBothEdges(a, b Node, e Edge)
	AllNodes() []Node
	EdgesNeighbors(a Node) ([]Edge, []Node)
}

type Keyer

type Keyer interface {
	Key() string
}

type MultiDag

type MultiDag[Node, Edge Keyer] struct {
	Nodes     []Node
	NodeMap   map[string]int
	Edges     []Edge
	EdgeMap   map[string]int
	EdgeNodes map[int]map[int]int
}

func (*MultiDag[Node, Edge]) AddBothEdges

func (g *MultiDag[Node, Edge]) AddBothEdges(a, b Node, e Edge)

func (*MultiDag[Node, Edge]) AddEdge

func (g *MultiDag[Node, Edge]) AddEdge(a, b Node, e Edge)

func (MultiDag[Node, Edge]) AllNodes

func (g MultiDag[Node, Edge]) AllNodes() []Node

func (MultiDag[Node, Edge]) EdgesNeighbors

func (g MultiDag[Node, Edge]) EdgesNeighbors(a Node) ([]Edge, []Node)

type UDGraph

type UDGraph[Node comparable, Edge any] AbstractGraph[Node, Edge]

func NewUDGraph

func NewUDGraph[Node comparable, Edge any]() UDGraph[Node, Edge]

func (UDGraph[Node, Edge]) AddBothEdges

func (g UDGraph[Node, Edge]) AddBothEdges(a, b Node, edge Edge)

func (UDGraph[Node, Edge]) AddEdge

func (g UDGraph[Node, Edge]) AddEdge(a, b Node, edge Edge)

func (UDGraph[Node, Edge]) AllNodes

func (g UDGraph[Node, Edge]) AllNodes() []Node

func (UDGraph[Node, Edge]) EdgesNeighbors

func (g UDGraph[Node, Edge]) EdgesNeighbors(a Node) ([]Edge, []Node)

Jump to

Keyboard shortcuts

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