graph

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 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 AdjGraph[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 AdjGraph added in v0.0.25

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

func FromDot

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

func FromDotDigraph added in v0.0.25

func FromDotDigraph[Node comparable, Edge any](path string, convert func(string) Node) (AdjGraph[Node, Edge], error)

func FromDotGraph added in v0.0.25

func FromDotGraph[Node comparable, Edge any](path string, convert func(string) Node) (AdjGraph[Node, Edge], error)

func LoadGraphFromJSON

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

func NewAdjGraph added in v0.0.25

func NewAdjGraph[Node comparable, Edge any]() AdjGraph[Node, Edge]

func (AdjGraph[Node, Edge]) AddBothEdges added in v0.0.25

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

func (AdjGraph[Node, Edge]) AddEdge added in v0.0.25

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

func (AdjGraph[Node, Edge]) AllNodes added in v0.0.25

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

func (AdjGraph[Node, Edge]) EdgesNeighbors added in v0.0.25

func (g AdjGraph[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)

Jump to

Keyboard shortcuts

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