graph

package
v0.1.93 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: GPL-3.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	Nodes map[godip.Province]*Node
}

func New

func New() *Graph

func (*Graph) AllFlags

func (self *Graph) AllFlags(n godip.Province) (result map[godip.Flag]bool)

func (*Graph) AllSCs

func (self *Graph) AllSCs() (result []godip.Province)

func (*Graph) Coasts

func (self *Graph) Coasts(prov godip.Province) (result []godip.Province)

func (*Graph) Edges

func (self *Graph) Edges(n godip.Province, reverse bool) (result map[godip.Province]map[godip.Flag]bool)

Edges returns the edges leading away from the specified province, or if reverse is set to true then it instead returns the edges leading to it.

func (*Graph) Flags

func (self *Graph) Flags(n godip.Province) (result map[godip.Flag]bool)

func (*Graph) Has

func (self *Graph) Has(n godip.Province) (result bool)

func (*Graph) Nations

func (self *Graph) Nations() (result []godip.Nation)

func (*Graph) Path

func (self *Graph) Path(first, last godip.Province, reverse bool, filter godip.PathFilter) []godip.Province

Path returns a list of provinces that go from first to last. When reverse is set to true then all edges are traversed backwards (i.e. to find a root that a unit at last could use to get to first). The filter can be used to specify the type of provinces that the path can go through, but it can also be used as a callback function to allow extracting information about all potential matching paths (nb. last can be set to "" to use this callback with all reachable provinces from first).

func (*Graph) Prov

func (self *Graph) Prov(n godip.Province) *SubNode

func (*Graph) Provinces

func (self *Graph) Provinces() (result []godip.Province)

func (*Graph) SC

func (self *Graph) SC(n godip.Province) (result *godip.Nation)

func (*Graph) SCs

func (self *Graph) SCs(n godip.Nation) (result []godip.Province)

func (*Graph) String

func (self *Graph) String() string

type Node

type Node struct {
	Name godip.Province
	Subs map[godip.Province]*SubNode
	SC   *godip.Nation
	// contains filtered or unexported fields
}

func (*Node) String

func (self *Node) String() string

type SubNode

type SubNode struct {
	Name         godip.Province
	Edges        map[godip.Province]*edge
	ReverseEdges map[godip.Province]*edge
	Flags        map[godip.Flag]bool
	// contains filtered or unexported fields
}

func (*SubNode) Conn

func (self *SubNode) Conn(n godip.Province, flags ...godip.Flag) *SubNode

func (*SubNode) Done

func (self *SubNode) Done() *Graph

func (*SubNode) Flag

func (self *SubNode) Flag(flags ...godip.Flag) *SubNode

func (*SubNode) Prov

func (self *SubNode) Prov(n godip.Province) *SubNode

func (*SubNode) SC

func (self *SubNode) SC(n godip.Nation) *SubNode

func (*SubNode) String

func (self *SubNode) String() string

Jump to

Keyboard shortcuts

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