graph

package
v0.0.0-...-d8ed7c5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PARSE_NODE_COUNT = iota
	PARSE_EDGE_COUNT = iota
	PARSE_NODES      = iota
	PARSE_EDGES      = iota
)

fmi parse states

Variables

This section is empty.

Functions

func GraphAsString

func GraphAsString(g Graph) string

func WriteFmi

func WriteFmi(g Graph, filename string)

Types

type AdjacencyArrayGraph

type AdjacencyArrayGraph struct {
	Nodes []geo.Point

	Offsets []int
	// contains filtered or unexported fields
}

Implementation for static graphs

func NewAdjacencyArrayFromFmiFile

func NewAdjacencyArrayFromFmiFile(filename string) *AdjacencyArrayGraph

func NewAdjacencyArrayFromFmiString

func NewAdjacencyArrayFromFmiString(fmi string) *AdjacencyArrayGraph

func NewAdjacencyArrayFromGraph

func NewAdjacencyArrayFromGraph(g Graph) *AdjacencyArrayGraph

Create an AdjacencyArrayGraph from the given graph

func (*AdjacencyArrayGraph) ArcCount

func (aag *AdjacencyArrayGraph) ArcCount() int

Returns the total number of arcs in the graph

func (*AdjacencyArrayGraph) AsString

func (aag *AdjacencyArrayGraph) AsString() string

Returns a human readable string of the graph

func (*AdjacencyArrayGraph) GetArcsFrom

func (aag *AdjacencyArrayGraph) GetArcsFrom(id NodeId) []Arc

Get the Arcs for the given node id

func (*AdjacencyArrayGraph) GetNode

func (aag *AdjacencyArrayGraph) GetNode(id NodeId) *geo.Point

Get the node for the given id

func (*AdjacencyArrayGraph) GetNodes

func (aag *AdjacencyArrayGraph) GetNodes() []geo.Point

get all nodes of the graph

func (*AdjacencyArrayGraph) NodeCount

func (aag *AdjacencyArrayGraph) NodeCount() int

Returns the number of Nodes in the graph

func (*AdjacencyArrayGraph) SetArcFlags

func (aag *AdjacencyArrayGraph) SetArcFlags(id NodeId, flag bool)

Set the arc flags for all arcs of the given node

func (*AdjacencyArrayGraph) SortArcs

func (aag *AdjacencyArrayGraph) SortArcs()

type AdjacencyListGraph

type AdjacencyListGraph struct {
	Nodes []geo.Point // The nodes of the graph
	Edges [][]Arc     // The Arcs of the graph. The first slice specifies to which the arc belongs
	// contains filtered or unexported fields
}

Implementation for dynamic graphs

func NewAdjacencyListFromFmiFile

func NewAdjacencyListFromFmiFile(filename string) *AdjacencyListGraph

func NewAdjacencyListFromFmiString

func NewAdjacencyListFromFmiString(fmi string) *AdjacencyListGraph

func (*AdjacencyListGraph) AddArc

func (alg *AdjacencyListGraph) AddArc(from, to NodeId, distance int) bool

Add an arc to the graph, going from source to target with the given distance

func (*AdjacencyListGraph) AddNode

func (alg *AdjacencyListGraph) AddNode(n geo.Point)

Add a node to the graph

func (*AdjacencyListGraph) ArcCount

func (alg *AdjacencyListGraph) ArcCount() int

Return the numebr of total arcs

func (*AdjacencyListGraph) AsString

func (alg *AdjacencyListGraph) AsString() string

Return a human readable string of the graph

func (*AdjacencyListGraph) GetArcsFrom

func (alg *AdjacencyListGraph) GetArcsFrom(id NodeId) []Arc

Get the arcs for the given node

func (*AdjacencyListGraph) GetNode

func (alg *AdjacencyListGraph) GetNode(id NodeId) *geo.Point

Return the node for the given id

func (*AdjacencyListGraph) GetNodes

func (alg *AdjacencyListGraph) GetNodes() []geo.Point

Return all nodes of the graph

func (*AdjacencyListGraph) NodeCount

func (alg *AdjacencyListGraph) NodeCount() int

Return the number of total nodes

func (*AdjacencyListGraph) SetArcFlags

func (alg *AdjacencyListGraph) SetArcFlags(id NodeId, flag bool)

Set the arc flags for all arcs of the given node

func (*AdjacencyListGraph) SortArcs

func (alg *AdjacencyListGraph) SortArcs()

type Arc

type Arc struct {
	To       NodeId
	Distance int
	// contains filtered or unexported fields
}

func MakeArc

func MakeArc(to NodeId, distance int, arcFlag bool) Arc

func NewArc

func NewArc(to NodeId, distance int, arcFlag bool) *Arc

func (Arc) ArcFlag

func (a Arc) ArcFlag() bool

func (Arc) Cost

func (a Arc) Cost() int

func (Arc) Destination

func (a Arc) Destination() NodeId

func (*Arc) SetArcFlag

func (a *Arc) SetArcFlag(flag bool)

type Arcs

type Arcs = []Arc

type DynamicGraph

type DynamicGraph interface {
	Graph
	AddNode(n geo.Point)
	AddArc(from, to NodeId, distance int) bool
}

type Edge

type Edge struct {
	From     NodeId
	To       NodeId
	Distance int
	// contains filtered or unexported fields
}

func MakeEdge

func MakeEdge(from, to NodeId, distance int, arcFlag bool) Edge

func NewEdge

func NewEdge(to, from NodeId, distance int, arcFlag bool) *Edge

func (Edge) ArcFlag

func (e Edge) ArcFlag() bool

func (Edge) Cost

func (e Edge) Cost() int

func (Edge) Destination

func (e Edge) Destination() NodeId

func (Edge) Invert

func (e Edge) Invert() Edge

func (*Edge) SetArcFlag

func (e *Edge) SetArcFlag(flag bool)

type Graph

type Graph interface {
	GetNode(id NodeId) *geo.Point
	GetNodes() []geo.Point
	GetArcsFrom(id NodeId) []Arc
	NodeCount() int
	ArcCount() int
	AsString() string
	SortArcs()
}

type NodeId

type NodeId = int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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