Documentation ¶
Overview ¶
Package gl implements graph using adjacency list and linked list data structure.
Index ¶
- type Edge
- type Graph
- func (g *Graph) Connect(A, B *Vertex, weight float64)
- func (g *Graph) CreateAndAddToGraph(id string) *Vertex
- func (g *Graph) DeleteEdge(A, B *Vertex)
- func (g *Graph) DeleteVertex(A *Vertex)
- func (g Graph) FindVertexByID(id interface{}) *Vertex
- func (g Graph) GetEdgeWeight(src, dst *Vertex) float64
- func (g Graph) GetEdges() *list.List
- func (g Graph) GetEdgesSize() int
- func (g Graph) GetVertices() *list.List
- func (g Graph) GetVerticesSize() int
- func (g Graph) ImmediateDominate(A, B *Vertex) bool
- func (g *Graph) UpdateWeight(src, dst *Vertex, value float64)
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
Graph is a graph represented in adjacency list. Vertices and edges are stored in linked list. Look at how linked list is implemented in Go's source code. Edges only needs to be handled by a graph, not by each vertex. Vertex contains a list of incoming and outgoing vertices, as in linked list. Let's suffix with T to differentiate with other types of graphs.
func ParseToGraph ¶
ParseToGraph parses string data to return a new graph.
func (*Graph) CreateAndAddToGraph ¶
CreateAndAddToGrammar finds the vertex with the ID, or create it.
func (*Graph) DeleteEdge ¶
DeleteEdge deletes the edge from the vertex A to B. Note that this only delete one direction from A to B.
func (*Graph) DeleteVertex ¶
DeleteVertex deletes a Vertex from the graph.
func (Graph) FindVertexByID ¶
FindVertexByID returns the vertex with input ID , or return nil if it doesn't exist.
func (Graph) GetEdgeWeight ¶
GetEdgeWeight returns the weight value.
func (Graph) GetEdgesSize ¶
GetEdgesSize returns the size of edge list in a graph.
func (Graph) GetVertices ¶
GetVertices returns the vertex list.
func (Graph) GetVerticesSize ¶
GetVerticesSize returns the size of vertex list in a graph.
func (Graph) ImmediateDominate ¶
ImmediateDominate returns true if A immediately dominates B. That is, true if A can go to B with only one edge.
func (*Graph) UpdateWeight ¶
UpdateWeight updates the weight value.
type Vertex ¶
type Vertex struct { ID string Color string // list of vertices that goes into this vertex // (vertices that precede this vertex in graph) InVertices *list.List // list of vertices that go out of this vertex OutVertices *list.List // time stamp to record the distance // from source vertex StampD int64 // another timestamp to be used in other algorithms StampF int64 }
Vertex is a vertex(node) in Graph.
func (Vertex) GetInVertices ¶
GetInVertices returns a list of adjacent vertices that goes to vertex v.
func (Vertex) GetOutVertices ¶
GetOutVertices returns a list of adjacent vertices from vertex v.