mapgraph

package
v0.0.0-...-2bb1cf3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	// Unique identifier of the source Cell
	S uint64 `json:"src"`

	// Unique identifier of the destination Cell
	D uint64 `json:"dst"`
}

Edge is ... an edge of the transportation directed graph

type Map

type Map struct {
	// The unique name of the map
	ID    string        `json:"id"`
	Cells SetOfVertices `json:"sites"`
	Roads SetOfEdges    `json:"roads"`
	// contains filtered or unexported fields
}

Map is a directed graph destined to be used as a transport network, organised as an adjacency list.

func EmptyMap

func EmptyMap() Map

EmptyMap builds a graph with no edge and no vertex.

func NewMap

func NewMap() *Map

NewMap returns a pointer to an EmptyMap

func (*Map) CellAdjacency

func (m *Map) CellAdjacency(id uint64) []uint64

CellAdjacency returns the adjacency list of the cell with the given ID, in other words, an array of the ID of the target of the roads leaving the given cell.

func (*Map) CellGet

func (m *Map) CellGet(id uint64) *Vertex

CellGet is a shortcut to get a node / vertex given its ID

func (*Map) CellHas

func (m *Map) CellHas(id uint64) bool

CellHas is a shortcut to check the presence of a node / vertex given its ID

func (*Map) Load

func (m *Map) Load(in io.Reader) error

Load consumes a mapclient.MapRaw from os.Stdin and populates the current Map accordingly.

func (*Map) LoadJSON

func (m *Map) LoadJSON(in string) error

LoadJSON is for testing purpose.

func (*Map) PathNextStep

func (m *Map) PathNextStep(src, dst uint64) (uint64, error)

PathNextStep computes the next step on the path from the source (given by src) to the destination (given by dst).

func (*Map) RoadHas

func (m *Map) RoadHas(src, dst uint64) bool

RoadHas is a shortcut to check the presence of an edge given its source and destination.

type SetOfEdges

type SetOfEdges []*Edge

func (*SetOfEdges) Add

func (s *SetOfEdges) Add(a *Edge)

func (SetOfEdges) Check

func (s SetOfEdges) Check() error

func (SetOfEdges) CheckThenFail

func (s SetOfEdges) CheckThenFail()

func (SetOfEdges) First

func (s SetOfEdges) First(at uint64) int

func (SetOfEdges) Get

func (s SetOfEdges) Get(f0 uint64, f1 uint64) *Edge

func (SetOfEdges) Has

func (s SetOfEdges) Has(f0 uint64, f1 uint64) bool

func (SetOfEdges) Len

func (s SetOfEdges) Len() int

func (SetOfEdges) Less

func (s SetOfEdges) Less(i, j int) bool

func (*SetOfEdges) Remove

func (s *SetOfEdges) Remove(a *Edge)

func (*SetOfEdges) RemovePK

func (s *SetOfEdges) RemovePK(f0 uint64, f1 uint64)

func (SetOfEdges) Slice

func (s SetOfEdges) Slice(m0 uint64, m1 uint64, max uint32) []*Edge

func (SetOfEdges) Swap

func (s SetOfEdges) Swap(i, j int)

type SetOfMaps

type SetOfMaps []*Map

func (*SetOfMaps) Add

func (s *SetOfMaps) Add(a *Map)

func (SetOfMaps) Check

func (s SetOfMaps) Check() error

func (SetOfMaps) CheckThenFail

func (s SetOfMaps) CheckThenFail()

func (SetOfMaps) Get

func (s SetOfMaps) Get(id string) *Map

func (SetOfMaps) Has

func (s SetOfMaps) Has(id string) bool

func (SetOfMaps) Len

func (s SetOfMaps) Len() int

func (SetOfMaps) Less

func (s SetOfMaps) Less(i, j int) bool

func (*SetOfMaps) Remove

func (s *SetOfMaps) Remove(a *Map)

func (*SetOfMaps) RemovePK

func (s *SetOfMaps) RemovePK(pk string)

func (SetOfMaps) Slice

func (s SetOfMaps) Slice(marker string, max uint32) []*Map

func (SetOfMaps) Swap

func (s SetOfMaps) Swap(i, j int)

type SetOfVertices

type SetOfVertices []*Vertex

func (*SetOfVertices) Add

func (s *SetOfVertices) Add(a *Vertex)

func (SetOfVertices) Check

func (s SetOfVertices) Check() error

func (SetOfVertices) CheckThenFail

func (s SetOfVertices) CheckThenFail()

func (SetOfVertices) Get

func (s SetOfVertices) Get(id uint64) *Vertex

func (SetOfVertices) Has

func (s SetOfVertices) Has(id uint64) bool

func (SetOfVertices) Len

func (s SetOfVertices) Len() int

func (SetOfVertices) Less

func (s SetOfVertices) Less(i, j int) bool

func (*SetOfVertices) Remove

func (s *SetOfVertices) Remove(a *Vertex)

func (*SetOfVertices) RemovePK

func (s *SetOfVertices) RemovePK(pk uint64)

func (SetOfVertices) Slice

func (s SetOfVertices) Slice(marker uint64, max uint32) []*Vertex

func (SetOfVertices) Swap

func (s SetOfVertices) Swap(i, j int)

type Vertex

type Vertex struct {
	// The unique identifier of the current cell.
	ID uint64 `json:"id"`

	// Location of the Cell on the map. Used for rendering
	X uint64 `json:"x"`
	Y uint64 `json:"y"`

	// Should the current location carry a city when the region starts,
	// and if yes, what should be the name of that city.
	City string `json:"city,omitempty"`
}

Vertex is a vertex in the transportation directed graph

Jump to

Keyboard shortcuts

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