Documentation ¶
Overview ¶
Package gt implements graph using adjacency matrix and map data structure.
Index ¶
- func Output2DSlice(mat [][]float64) string
- type Graph
- func (g *Graph) AddEdge(A, B string, val float64)
- func (g Graph) GetEdgeWeight(A, B string) float64
- func (g Graph) GetEdgesSize() int
- func (g Graph) GetInVertices(A string) []string
- func (g Graph) GetOutVertices(A string) []string
- func (g Graph) GetVertices() []string
- func (g Graph) GetVerticesSize() int
- func (g Graph) HasEdge(A, B string) bool
- func (g *Graph) Initialize(num float64)
- func (g Graph) OutputMatrix() string
- func (g *Graph) RemoveEdge(A, B string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Output2DSlice ¶
Output2DSlice outputs the matrix in string format.
Types ¶
type Graph ¶
type Graph struct { Size *int Matrix [][]float64 // to look up the index of vertex Index map[string]int // to look up the string label from index Label map[int]string }
Graph is a graph represented in adjacency matrix.
func NewGraph ¶
NewGraph returns a new graph in adjacency matrix. It returns the adjacency matrix of the size * size.
func ParseToGraph ¶
ParseToGraph parses string data to return a new graph.
func (*Graph) AddEdge ¶
AddEdge adds an edge with the weight value. The edge goes from A to B, not B to A.
func (Graph) GetEdgeWeight ¶
GetEdgeWeight returns the value of the matrix which is the edge weight value from A to B.
func (Graph) GetEdgesSize ¶
GetEdgesSize returns the size of edges.
func (Graph) GetInVertices ¶
GetInVertices returns the vertices that goes into A.
func (Graph) GetOutVertices ¶
GetOutVertices returns the vertices that goes out of A.
func (Graph) GetVertices ¶
GetVertices returns the slice of vertices.
func (Graph) GetVerticesSize ¶
GetVerticesSize returns the size of vertices.
func (*Graph) Initialize ¶
Initialize initializes the elements of matrix with num.
func (Graph) OutputMatrix ¶
OutputMatrix outputs the matrix of Graph in string format.
func (*Graph) RemoveEdge ¶
RemoveEdge removes an edge from A to B, not B to A.