Documentation
¶
Index ¶
- func PageRank()
- func ShortestPath()
- func TopologicalSort()
- type AdjIndex
- func (a *AdjIndex) AdjacentTo(v *Vertex) []*Vertex
- func (a *AdjIndex) EdgeAdd(e *Edge, from, to *Vertex)
- func (a *AdjIndex) EdgeRemove(e *Edge, from, to *Vertex)
- func (a *AdjIndex) Name() string
- func (a *AdjIndex) UUID() UUID
- func (a *AdjIndex) UUIDString() string
- func (a *AdjIndex) VertexAdd(v *Vertex)
- func (a *AdjIndex) VertexRemove(v *Vertex)
- type Edge
- type Graph
- func (g *Graph) AddEdge(e *Edge, src, dst *Vertex) bool
- func (g *Graph) AddVertex(v *Vertex) bool
- func (g *Graph) Adjacent(v *Vertex) map[*Vertex]int
- func (g *Graph) BFS(root *Vertex) (map[*Vertex]*Vertex, map[*Vertex]int)
- func (g *Graph) DFS(root *Vertex)
- func (g *Graph) Dijkstras(root *Vertex) (map[*Vertex]*Vertex, map[*Vertex]int)
- func (g *Graph) Edge(u UUID) (*Edge, bool)
- func (g *Graph) Edges() map[string]*Edge
- func (g *Graph) EdgesFrom(v *Vertex) map[string]*Edge
- func (g *Graph) EdgesOf(v *Vertex) map[string]*Edge
- func (g *Graph) EdgesTo(v *Vertex) map[string]*Edge
- func (g *Graph) InDegree(v *Vertex) int
- func (g *Graph) OutDegree(v *Vertex) int
- func (g *Graph) RemoveEdge(e *Edge, src, dst *Vertex) bool
- func (g *Graph) RemoveVertex(v *Vertex) bool
- func (g *Graph) ReverseAdjacent(v *Vertex) map[*Vertex]int
- func (g *Graph) Vertex(u UUID) (*Vertex, bool)
- func (g *Graph) Vertices() map[string]*Vertex
- type Path
- type Queue
- type Stack
- type Vertex
- func (v *Vertex) Equal(x *Vertex) bool
- func (v *Vertex) GetProperties() map[string]int
- func (v *Vertex) Key() int
- func (v *Vertex) Member(g *Graph) bool
- func (v *Vertex) Type() string
- func (v *Vertex) UUID() UUID
- func (v *Vertex) UUIDString() string
- func (v *Vertex) UpdateProperties(p map[string]int) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdjIndex ¶
type AdjIndex struct {
// contains filtered or unexported fields
}
func NewAdjIndex ¶
func NewAdjIndex() *AdjIndex
func (*AdjIndex) AdjacentTo ¶
func (*AdjIndex) EdgeRemove ¶
func (*AdjIndex) UUIDString ¶
func (*AdjIndex) VertexRemove ¶
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
The Edge struct.
func NewEdge ¶
Allocated a new Edge and returns a pointer to it. //func NewEdge(weight int, relation string) *Edge {
func (*Edge) Properties ¶
Returns a copy of the properties field of an Edge.
func (*Edge) UpdateProperties ¶
Replaces the properties of e with p.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Could make it so that the mapping of adjacency and revAdjacency is to weights. Also the adj maps don't account for multiple types of Edges connecting Vertices.
func (*Graph) BFS ¶
The return order is (map[child]parent, map[destination]cost) This functions returns: (child -> parent *Vertex), (*Vertex -> cost). This allows a user to construct the shortest path for any *Vertex from root.
func (*Graph) InDegree ¶
Get the In-degree of a Vertex. A return value of -1 indicates the Vertex has no entry in the revAdjacency map. -1 implies v does not exist.
func (*Graph) OutDegree ¶
Get the Out-degree of a Vertex. A return value of -1 indicates the Vertex has no entry in the adjacency map. -1 implies v does not exist.
func (*Graph) RemoveEdge ¶
Remove an Edge e between Vertex src and Vertex dst from g. always returns true. This function deletes 1 entry in each of g.adjacency and g.revAdjacency. Finally it deletes e from g.edges. This deleteion does not account for multiple Edges between two Vertices. Constant time operation.
func (*Graph) RemoveVertex ¶
Remove a Vertex v from g also removing all Edges with their source at v. Runs in time proportional to: (number of Vertices to which v is adjacent) + (number of Vertices that are adjacent to v) + (number of edges in/out of v)
func (*Graph) ReverseAdjacent ¶
Return the reverse adjacency map of v in g.
type Vertex ¶
type Vertex struct {
// contains filtered or unexported fields
}
The Vertex struct.
func (*Vertex) GetProperties ¶
Returns a copy of the props map of v.
func (*Vertex) UUID ¶
func (v *Vertex) UUID() UUID
Returns the uuid of v as a UUID which is an alias for [16]byte
func (*Vertex) UUIDString ¶
Returns the string representation of the uuid for v.