Documentation ¶
Overview ¶
Package model provides model structs for a directed weighted graph.
Index ¶
- type Account
- type ByTime
- type DijkstraPrio
- type Edge
- type Graph
- type Node
- func (node *Node) AddFromEdge(edge *Edge)
- func (node *Node) AddReward(reward *Reward, quantity int)
- func (node *Node) AddToEdge(edge *Edge)
- func (node *Node) FromEdges() []*Edge
- func (node *Node) ID() string
- func (node *Node) MinPathLeft() int
- func (node *Node) Revisitable() bool
- func (node *Node) Rewards() map[*Reward]int
- func (node *Node) SetMinPathLeft(mpl int)
- func (node *Node) ToEdges() []*Edge
- type Path
- func (path *Path) AddEdge(edge *Edge, i int)
- func (path *Path) AddRewards(rewards map[*Reward]int)
- func (path *Path) Copy() *Path
- func (path *Path) Edges() []*Edge
- func (path *Path) IsLongerThan(other *Path) bool
- func (path *Path) Length() int
- func (path *Path) PossibleRoute(edge *Edge) (isPossible bool, index int)
- func (path *Path) Rewards() map[*Reward]int
- type PrioQueue
- type Reward
- type Websession
- type Weight
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { ID int Username string DisplayName string Password string Created time.Time LastUpdated time.Time }
Account contains all information regarding user accounts.
func (*Account) CreateAccount ¶
CreateAccount creates and stores a new account to the database.
type ByTime ¶
type ByTime []*Weight
ByTime is a list of Weights which implements the sort interface.
type DijkstraPrio ¶
type DijkstraPrio []*Node
DijkstraPrio is a list of node pointers and implements heap interface
func (DijkstraPrio) Less ¶
func (dp DijkstraPrio) Less(i, j int) bool
Less checks which node has shorter minimum path left to end node
func (*DijkstraPrio) Pop ¶
func (dp *DijkstraPrio) Pop() interface{}
Pop returns the node with the shortest minimum path left to end node
func (*DijkstraPrio) Push ¶
func (dp *DijkstraPrio) Push(x interface{})
Push adds a node into DijkstraPrio list to the correct place
func (DijkstraPrio) Swap ¶
func (dp DijkstraPrio) Swap(i, j int)
Swap switches places in the DijkstraPrio list
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
Edge contains pointers to from and to nodes as well as a list of weights.
func CreateEdge ¶
CreateEdge takes from and to node pointers and returns a pointer to a new edge.
func (*Edge) FastestTime ¶
FastestTime returns the fastest possible time this edge's weights can provide.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph includes pointers to startNode, endNode and the internal type prioQueue.
func CreateGraph ¶
CreateGraph is the constructor for graph taking pointers to startNode and endNode as parameters.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node stores all information about nodes like neighboring edges, rewards and if it's revisitable.
func CreateNode ¶
CreateNode takes id and revisitable as paramteres, returning a pointer to the new node
func (*Node) AddFromEdge ¶
AddFromEdge adds an edge which has this node as a from edge.
func (*Node) MinPathLeft ¶
MinPathLeft returns minimum path left to end node or math.MaxInt32 if not known.
func (*Node) Revisitable ¶
Revisitable returns true if the node is revisitable
func (*Node) SetMinPathLeft ¶
SetMinPathLeft sets the minimum path left to end node.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path holds information about a possible path, including edges, current length and current rewards.
func (*Path) AddRewards ¶
AddRewards adds a map of rewards to the path.
func (*Path) IsLongerThan ¶
IsLongerThan compares two paths to see which has best potential to be the shortest path.
func (*Path) PossibleRoute ¶
PossibleRoute checks if an edge makes an eligible route to take for the current path.
type PrioQueue ¶
type PrioQueue []*Path
PrioQueue is a list of Path pointers and implements heap interface.
func (*PrioQueue) Pop ¶
func (pq *PrioQueue) Pop() interface{}
Pop returns the node with the best potential path for the shortest path.
type Reward ¶
type Reward struct {
// contains filtered or unexported fields
}
Reward stores reward id, if it is unique and if can be counted as another reward via inheritance.
func CreateReward ¶
CreateReward constructs a new Reward.
type Websession ¶
Websession contains all information regarding a single web session.
func CreateWebsession ¶
func CreateWebsession(dbpool *pgxpool.Pool, accountId int, hoursLoggedIn uint32) (*Websession, error)
CreateWebsession creates and stores a new web session to the database.
func (*Websession) String ¶
func (ws *Websession) String() string
type Weight ¶
type Weight struct {
// contains filtered or unexported fields
}
Weight holds the time and possible requirements to traverse an edge.
func CreateWeight ¶
CreateWeight constructs a weight and returns a pointer to it.
func (*Weight) AddRequirement ¶
AddRequirement adds a requirement with a quantity.
func (*Weight) Requirements ¶
Requirements returns a map of requirements.