Documentation ¶
Index ¶
- type DirectedDenseGraph
- func (g *DirectedDenseGraph) Edge(u, v graph.Node) graph.Edge
- func (g *DirectedDenseGraph) Edges() []graph.Edge
- func (g *DirectedDenseGraph) From(n graph.Node) []graph.Node
- func (g *DirectedDenseGraph) Has(n graph.Node) bool
- func (g *DirectedDenseGraph) HasEdge(x, y graph.Node) bool
- func (g *DirectedDenseGraph) HasEdgeFromTo(u, v graph.Node) bool
- func (g *DirectedDenseGraph) Matrix() mat64.Matrix
- func (g *DirectedDenseGraph) Nodes() []graph.Node
- func (g *DirectedDenseGraph) RemoveEdge(e graph.Edge)
- func (g *DirectedDenseGraph) SetEdgeWeight(e graph.Edge, weight float64)
- func (g *DirectedDenseGraph) To(n graph.Node) []graph.Node
- func (g *DirectedDenseGraph) Weight(e graph.Edge) float64
- type DirectedGraph
- func (g *DirectedGraph) AddNode(n graph.Node)
- func (g *DirectedGraph) Degree(n graph.Node) int
- func (g *DirectedGraph) Edge(u, v graph.Node) graph.Edge
- func (g *DirectedGraph) Edges() []graph.Edge
- func (g *DirectedGraph) EmptyGraph()
- func (g *DirectedGraph) From(n graph.Node) []graph.Node
- func (g *DirectedGraph) Has(n graph.Node) bool
- func (g *DirectedGraph) HasEdge(x, y graph.Node) bool
- func (g *DirectedGraph) HasEdgeFromTo(u, v graph.Node) bool
- func (g *DirectedGraph) NewNodeID() int
- func (g *DirectedGraph) Node(id int) graph.Node
- func (g *DirectedGraph) Nodes() []graph.Node
- func (g *DirectedGraph) RemoveEdge(e graph.Edge)
- func (g *DirectedGraph) RemoveNode(n graph.Node)
- func (g *DirectedGraph) SetEdge(e graph.Edge, cost float64)
- func (g *DirectedGraph) To(n graph.Node) []graph.Node
- func (g *DirectedGraph) Weight(e graph.Edge) float64
- type Edge
- type Graph
- func (g *Graph) AddNode(n graph.Node)
- func (g *Graph) Degree(n graph.Node) int
- func (g *Graph) Edge(u, v graph.Node) graph.Edge
- func (g *Graph) EdgeBetween(u, v graph.Node) graph.Edge
- func (g *Graph) Edges() []graph.Edge
- func (g *Graph) EmptyGraph()
- func (g *Graph) From(n graph.Node) []graph.Node
- func (g *Graph) Has(n graph.Node) bool
- func (g *Graph) HasEdge(n, neigh graph.Node) bool
- func (g *Graph) NewNodeID() int
- func (g *Graph) Node(id int) graph.Node
- func (g *Graph) Nodes() []graph.Node
- func (g *Graph) RemoveEdge(e graph.Edge)
- func (g *Graph) RemoveNode(n graph.Node)
- func (g *Graph) SetEdge(e graph.Edge, cost float64)
- func (g *Graph) Weight(e graph.Edge) float64
- type Node
- type UndirectedDenseGraph
- func (g *UndirectedDenseGraph) Degree(n graph.Node) int
- func (g *UndirectedDenseGraph) Edge(u, v graph.Node) graph.Edge
- func (g *UndirectedDenseGraph) EdgeBetween(u, v graph.Node) graph.Edge
- func (g *UndirectedDenseGraph) Edges() []graph.Edge
- func (g *UndirectedDenseGraph) From(n graph.Node) []graph.Node
- func (g *UndirectedDenseGraph) Has(n graph.Node) bool
- func (g *UndirectedDenseGraph) HasEdge(u, v graph.Node) bool
- func (g *UndirectedDenseGraph) Matrix() mat64.Matrix
- func (g *UndirectedDenseGraph) Nodes() []graph.Node
- func (g *UndirectedDenseGraph) RemoveEdge(e graph.Edge)
- func (g *UndirectedDenseGraph) SetEdgeWeight(e graph.Edge, weight float64)
- func (g *UndirectedDenseGraph) Weight(e graph.Edge) float64
- type WeightedEdge
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectedDenseGraph ¶ added in v1.0.3
type DirectedDenseGraph struct {
// contains filtered or unexported fields
}
DirectedDenseGraph represents a graph such that all IDs are in a contiguous block from 0 to n-1.
func NewDirectedDenseGraph ¶ added in v1.0.3
func NewDirectedDenseGraph(n int, passable bool, absent float64) *DirectedDenseGraph
NewDirectedDenseGraph creates a directed dense graph with n nodes. If passable is true all pairs of nodes will be connected by an edge with unit cost, otherwise every node will start unconnected with the cost specified by absent.
func (*DirectedDenseGraph) Edge ¶ added in v1.0.3
func (g *DirectedDenseGraph) Edge(u, v graph.Node) graph.Edge
func (*DirectedDenseGraph) Edges ¶ added in v1.0.3
func (g *DirectedDenseGraph) Edges() []graph.Edge
func (*DirectedDenseGraph) From ¶ added in v1.0.3
func (g *DirectedDenseGraph) From(n graph.Node) []graph.Node
func (*DirectedDenseGraph) Has ¶ added in v1.0.3
func (g *DirectedDenseGraph) Has(n graph.Node) bool
func (*DirectedDenseGraph) HasEdge ¶ added in v1.0.3
func (g *DirectedDenseGraph) HasEdge(x, y graph.Node) bool
func (*DirectedDenseGraph) HasEdgeFromTo ¶ added in v1.0.3
func (g *DirectedDenseGraph) HasEdgeFromTo(u, v graph.Node) bool
func (*DirectedDenseGraph) Matrix ¶ added in v1.0.3
func (g *DirectedDenseGraph) Matrix() mat64.Matrix
func (*DirectedDenseGraph) Nodes ¶ added in v1.0.3
func (g *DirectedDenseGraph) Nodes() []graph.Node
func (*DirectedDenseGraph) RemoveEdge ¶ added in v1.0.3
func (g *DirectedDenseGraph) RemoveEdge(e graph.Edge)
func (*DirectedDenseGraph) SetEdgeWeight ¶ added in v1.0.3
func (g *DirectedDenseGraph) SetEdgeWeight(e graph.Edge, weight float64)
type DirectedGraph ¶
type DirectedGraph struct {
// contains filtered or unexported fields
}
A Directed graph is a highly generalized MutableDirectedGraph.
In most cases it's likely more desireable to use a graph specific to your problem domain.
func NewDirectedGraph ¶
func NewDirectedGraph() *DirectedGraph
func (*DirectedGraph) AddNode ¶
func (g *DirectedGraph) AddNode(n graph.Node)
Adds a node to the graph. Implementation note: if you add a node close to or at the max int on your machine NewNode will become slower.
func (*DirectedGraph) Edge ¶ added in v1.0.3
func (g *DirectedGraph) Edge(u, v graph.Node) graph.Edge
func (*DirectedGraph) Edges ¶ added in v1.0.3
func (g *DirectedGraph) Edges() []graph.Edge
func (*DirectedGraph) EmptyGraph ¶
func (g *DirectedGraph) EmptyGraph()
func (*DirectedGraph) From ¶ added in v1.0.3
func (g *DirectedGraph) From(n graph.Node) []graph.Node
func (*DirectedGraph) HasEdge ¶ added in v1.0.3
func (g *DirectedGraph) HasEdge(x, y graph.Node) bool
func (*DirectedGraph) HasEdgeFromTo ¶ added in v1.0.3
func (g *DirectedGraph) HasEdgeFromTo(u, v graph.Node) bool
func (*DirectedGraph) NewNodeID ¶ added in v1.0.3
func (g *DirectedGraph) NewNodeID() int
func (*DirectedGraph) Nodes ¶ added in v1.0.3
func (g *DirectedGraph) Nodes() []graph.Node
func (*DirectedGraph) RemoveEdge ¶ added in v1.0.3
func (g *DirectedGraph) RemoveEdge(e graph.Edge)
func (*DirectedGraph) RemoveNode ¶
func (g *DirectedGraph) RemoveNode(n graph.Node)
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
A GonumGraph is a very generalized graph that can handle an arbitrary number of vertices and edges -- as well as act as either directed or undirected.
Internally, it uses a map of successors AND predecessors, to speed up some operations (such as getting all successors/predecessors). It also speeds up things like adding edges (assuming both edges exist).
However, its generality is also its weakness (and partially a flaw in needing to satisfy MutableGraph). For most purposes, creating your own graph is probably better. For instance, see TileGraph for an example of an immutable 2D grid of tiles that also implements the Graph interface, but would be more suitable if all you needed was a simple undirected 2D grid.
func (*Graph) EmptyGraph ¶
func (g *Graph) EmptyGraph()
func (*Graph) RemoveEdge ¶ added in v1.0.3
func (*Graph) RemoveNode ¶
type UndirectedDenseGraph ¶ added in v1.0.3
type UndirectedDenseGraph struct {
// contains filtered or unexported fields
}
UndirectedDenseGraph represents a graph such that all IDs are in a contiguous block from 0 to n-1.
func NewUndirectedDenseGraph ¶ added in v1.0.3
func NewUndirectedDenseGraph(n int, passable bool, absent float64) *UndirectedDenseGraph
NewUndirectedDenseGraph creates an undirected dense graph with n nodes. If passable is true all pairs of nodes will be connected by an edge with unit cost, otherwise every node will start unconnected with the cost specified by absent.
func (*UndirectedDenseGraph) Degree ¶ added in v1.0.3
func (g *UndirectedDenseGraph) Degree(n graph.Node) int
func (*UndirectedDenseGraph) Edge ¶ added in v1.0.3
func (g *UndirectedDenseGraph) Edge(u, v graph.Node) graph.Edge
func (*UndirectedDenseGraph) EdgeBetween ¶ added in v1.0.3
func (g *UndirectedDenseGraph) EdgeBetween(u, v graph.Node) graph.Edge
func (*UndirectedDenseGraph) Edges ¶ added in v1.0.3
func (g *UndirectedDenseGraph) Edges() []graph.Edge
func (*UndirectedDenseGraph) From ¶ added in v1.0.3
func (g *UndirectedDenseGraph) From(n graph.Node) []graph.Node
func (*UndirectedDenseGraph) Has ¶ added in v1.0.3
func (g *UndirectedDenseGraph) Has(n graph.Node) bool
func (*UndirectedDenseGraph) HasEdge ¶ added in v1.0.3
func (g *UndirectedDenseGraph) HasEdge(u, v graph.Node) bool
func (*UndirectedDenseGraph) Matrix ¶ added in v1.0.3
func (g *UndirectedDenseGraph) Matrix() mat64.Matrix
func (*UndirectedDenseGraph) Nodes ¶ added in v1.0.3
func (g *UndirectedDenseGraph) Nodes() []graph.Node
func (*UndirectedDenseGraph) RemoveEdge ¶ added in v1.0.3
func (g *UndirectedDenseGraph) RemoveEdge(e graph.Edge)
func (*UndirectedDenseGraph) SetEdgeWeight ¶ added in v1.0.3
func (g *UndirectedDenseGraph) SetEdgeWeight(e graph.Edge, weight float64)