Documentation ¶
Index ¶
- type Edge
- type Graph
- func (g *Graph) AddEdge(from, to Vertex, weight int) error
- func (g *Graph) AddVertex(v Vertex) error
- func (g *Graph) ExistsEdge(from, to Vertex) bool
- func (g *Graph) ExistsVertex(v Vertex) bool
- func (g *Graph) GetEdges() []Edge
- func (g *Graph) GetNeighbours(v Vertex) []Vertex
- func (g *Graph) GetVertices() []Vertex
- func (g *Graph) GetWeight(from, to Vertex) (int, error)
- func (g *Graph) RemoveEdge(from, to Vertex) error
- func (g *Graph) RemoveVertex(v Vertex) error
- func (g *Graph) SetDir(dir bool)
- func (g *Graph) SetWeight(from, to Vertex, weight int) error
- func (g *Graph) Visualize() error
- type VerSet
- func (s VerSet) Add(v Vertex) error
- func (s VerSet) Cardinality() int
- func (s VerSet) Contains(v Vertex) bool
- func (s VerSet) Difference(other VerSet) VerSet
- func (s VerSet) Equal(other VerSet) bool
- func (s VerSet) Intersect(other VerSet) VerSet
- func (s VerSet) Remove(v Vertex) error
- func (s VerSet) Union(other VerSet) VerSet
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct { Vertices map[Vertex]int VerticesCount int Edges map[Edge]int EdgesCount int IsDirected bool Neighbours map[Vertex][]Vertex }
Graph represents a shape of whole graph To use constructer in my program, the first character of the Identifier's name must be a Unicode upper case
func (*Graph) AddEdge ¶
AddEdge adds an edge difined by `from` and `to` to the graph `g`. If a graph has already have the edge, it returns an error. The graph g must have the vertices `from` and `to`, if `g` don't have `from` or `to`, AddEdge returns an error. The vertices `from` and `to` must be different.
func (*Graph) AddVertex ¶
AddVertex adds a vertex `v` to the graph `g`. If a graph has already have the vertex `v`, it returns an error
func (*Graph) ExistsEdge ¶
ExistsEdge chech whether the edge difined by `from` and `to` exists in the graph `g`, or not
func (*Graph) ExistsVertex ¶
ExistsVertex chech whether the vertex `v` exists in the graph `g`, or not
func (*Graph) GetNeighbours ¶
GetNeighbours returns the neighbours of the Vertex `v`.
func (*Graph) GetVertices ¶
GetVertices returns slice of Vertices
func (*Graph) GetWeight ¶
GetWeight returns a weight of the edge difined by `from` and `to`. The vertices `from` and `to` must be different. The edge must exist.
func (*Graph) RemoveEdge ¶
RemoveEdge removes an edge difined by `from` and `to`, form the graph `g`. The vertices `from` and `to` must be different.
func (*Graph) RemoveVertex ¶
RemoveVertex remove a vertex form the graph `g`.
type VerSet ¶
type VerSet map[Vertex]struct{}
VerSet represents a set of vertices.
func (VerSet) Cardinality ¶
Cardinality returns the number of elements in the Set.
func (VerSet) Difference ¶
Difference returns the difference of `s` and `other`. Difference have a referential transparency.