Documentation
¶
Index ¶
- type BasicGraph
- type DirectedGraph
- type Graph
- type MultiGraph
- type WeightedEdge
- type WeightedGraph
- func (g *WeightedGraph) AddEdge(vertex1, vertex2 string, weight int)
- func (g *WeightedGraph) GetEdgeWeight(vertex1, vertex2 string) (int, bool)
- func (g *WeightedGraph) GetEdges() []WeightedEdge
- func (g *WeightedGraph) GetNeighbors(vertex string) map[string]int
- func (g *WeightedGraph) HasEdge(vertex1, vertex2 string) bool
- func (g *WeightedGraph) RemoveEdge(vertex1, vertex2 string)
- type WeightedOrientedGraph
- func (g *WeightedOrientedGraph) AddEdge(vertex1, vertex2 string, weight int)
- func (g *WeightedOrientedGraph) GetEdgeWeight(vertex1, vertex2 string) (int, bool)
- func (g *WeightedOrientedGraph) GetNeighbors(vertex string) map[string]int
- func (g *WeightedOrientedGraph) HasEdge(vertex1, vertex2 string) bool
- func (g *WeightedOrientedGraph) RemoveEdge(vertex1, vertex2 string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicGraph ¶
func NewBasicGraph ¶
func NewBasicGraph() *BasicGraph
func (*BasicGraph) AddEdge ¶
func (g *BasicGraph) AddEdge(vertex1, vertex2 string)
func (*BasicGraph) GetNeighbors ¶
func (g *BasicGraph) GetNeighbors(vertex string) []string
func (*BasicGraph) HasEdge ¶
func (g *BasicGraph) HasEdge(vertex1, vertex2 string) bool
func (*BasicGraph) RemoveEdge ¶
func (g *BasicGraph) RemoveEdge(vertex1, vertex2 string)
type DirectedGraph ¶
func NewDirectedGraph ¶
func NewDirectedGraph() *DirectedGraph
func (*DirectedGraph) AddEdge ¶
func (g *DirectedGraph) AddEdge(vertex1, vertex2 string)
func (*DirectedGraph) GetNeighbors ¶
func (g *DirectedGraph) GetNeighbors(vertex string) []string
func (*DirectedGraph) HasEdge ¶
func (g *DirectedGraph) HasEdge(vertex1, vertex2 string) bool
func (*DirectedGraph) RemoveEdge ¶
func (g *DirectedGraph) RemoveEdge(vertex1, vertex2 string)
type MultiGraph ¶
func NewMultiGraph ¶
func NewMultiGraph() *MultiGraph
func (*MultiGraph) AddEdge ¶
func (g *MultiGraph) AddEdge(vertex1, vertex2 string)
func (*MultiGraph) GetNeighbors ¶
func (g *MultiGraph) GetNeighbors(vertex string) []string
func (*MultiGraph) HasEdge ¶
func (g *MultiGraph) HasEdge(vertex1, vertex2 string) bool
func (*MultiGraph) RemoveEdge ¶
func (g *MultiGraph) RemoveEdge(vertex1, vertex2 string)
func (*MultiGraph) String ¶
func (g *MultiGraph) String() string
type WeightedEdge ¶
WeightedEdge represents an edge in a weighted graph.
Fields:
U: The name of the first vertex (string). V: The name of the second vertex (string). Weight: The weight of the edge (int).
type WeightedGraph ¶
func NewWeightedGraph ¶
func NewWeightedGraph() *WeightedGraph
func (*WeightedGraph) AddEdge ¶
func (g *WeightedGraph) AddEdge(vertex1, vertex2 string, weight int)
func (*WeightedGraph) GetEdgeWeight ¶
func (g *WeightedGraph) GetEdgeWeight(vertex1, vertex2 string) (int, bool)
func (*WeightedGraph) GetEdges ¶
func (g *WeightedGraph) GetEdges() []WeightedEdge
Returns a slice of all edges in the graph.
IMPORTANT: The order of edges in the returned slice is NOT guaranteed to be deterministic.
The function relies on the invariant of the Vertices map (u < v for any edge (u, v)) to ensure that it only adds one representation of each undirected edge to the result.
func (*WeightedGraph) GetNeighbors ¶
func (g *WeightedGraph) GetNeighbors(vertex string) map[string]int
func (*WeightedGraph) HasEdge ¶
func (g *WeightedGraph) HasEdge(vertex1, vertex2 string) bool
func (*WeightedGraph) RemoveEdge ¶
func (g *WeightedGraph) RemoveEdge(vertex1, vertex2 string)
type WeightedOrientedGraph ¶
type WeightedOrientedGraph struct {
// contains filtered or unexported fields
}
func NewWeightedOrientedGraph ¶
func NewWeightedOrientedGraph() *WeightedOrientedGraph
func (*WeightedOrientedGraph) AddEdge ¶
func (g *WeightedOrientedGraph) AddEdge(vertex1, vertex2 string, weight int)
func (*WeightedOrientedGraph) GetEdgeWeight ¶
func (g *WeightedOrientedGraph) GetEdgeWeight(vertex1, vertex2 string) (int, bool)
func (*WeightedOrientedGraph) GetNeighbors ¶
func (g *WeightedOrientedGraph) GetNeighbors(vertex string) map[string]int
func (*WeightedOrientedGraph) HasEdge ¶
func (g *WeightedOrientedGraph) HasEdge(vertex1, vertex2 string) bool
func (*WeightedOrientedGraph) RemoveEdge ¶
func (g *WeightedOrientedGraph) RemoveEdge(vertex1, vertex2 string)
Click to show internal directories.
Click to hide internal directories.