Documentation
¶
Index ¶
- func DefaultCostGetter(g *Graph, source, target int) int
- type CostGetter
- type Graph
- func (g *Graph) AddEdge(src, dst, w int) bool
- func (g *Graph) AddVertex() int
- func (g *Graph) AllShortestPath(source, target int, cg CostGetter) [][]int
- func (g *Graph) GetAllNeighbours(source int) []int
- func (g *Graph) GetAllVertices() []*Vertex
- func (g *Graph) HasEdge(source, target int) bool
- func (g *Graph) Len() int
- func (g *Graph) PrintGraph()
- func (g *Graph) RemoveEdge(src, dst int) bool
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCostGetter ¶
DefaultCostGetter default cost getter
Types ¶
type CostGetter ¶
CostGetter weight前提肯定大于0
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph graph's vertex should be from 0 to n-1 when there are n vertices
func (*Graph) AllShortestPath ¶
func (g *Graph) AllShortestPath(source, target int, cg CostGetter) [][]int
AllShortestPath Computes all shortest paths between 2 vertices source: starting vertex ,target: end vertex
func (*Graph) GetAllNeighbours ¶
GetAllNeighbours return all neighbor nodes
func (*Graph) GetAllVertices ¶
GetAllVertices return all vertices
func (*Graph) RemoveEdge ¶
RemoveEdge remove a neighbor node
Click to show internal directories.
Click to hide internal directories.