Documentation
¶
Index ¶
- type Config
- type LabeledGraph
- func (g *LabeledGraph[V, L]) AddEdge(u, v V, l L)
- func (g *LabeledGraph[V, L]) AddVertex(v V)
- func (g *LabeledGraph[V, L]) ContainsEdge(u, v V) bool
- func (g *LabeledGraph[V, L]) ContainsVertex(v V) bool
- func (g *LabeledGraph[V, L]) Degree(u V) (int, bool)
- func (g *LabeledGraph[V, L]) Directed() bool
- func (g *LabeledGraph[V, L]) Edges() iter.Seq2[V, V]
- func (g *LabeledGraph[V, L]) InDegree(u V) (int, bool)
- func (g *LabeledGraph[V, L]) InIncidentEdges(v V) iter.Seq2[V, V]
- func (g *LabeledGraph[V, L]) IncidentEdges(v V) iter.Seq2[V, V]
- func (g *LabeledGraph[V, L]) Label(u, v V) (L, bool)
- func (g *LabeledGraph[V, L]) Neighbors(v V) iter.Seq[V]
- func (g *LabeledGraph[V, L]) Order() int
- func (g *LabeledGraph[V, L]) OutDegree(u V) (int, bool)
- func (g *LabeledGraph[V, L]) OutIncidentEdges(u V) iter.Seq2[V, V]
- func (g *LabeledGraph[V, L]) Predecessors(v V) iter.Seq[V]
- func (g *LabeledGraph[V, L]) RemoveEdge(u, v V)
- func (g *LabeledGraph[V, L]) RemoveVertex(v V)
- func (g *LabeledGraph[V, L]) SetLabel(u, v V, label L)
- func (g *LabeledGraph[V, L]) Size() int
- func (g *LabeledGraph[V, L]) Successors(u V) iter.Seq[V]
- func (g *LabeledGraph[V, L]) Vertices() iter.Seq[V]
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds configuration values for New to use when contracting a LabeledGraph.
type LabeledGraph ¶
type LabeledGraph[V comparable, L any] struct { // contains filtered or unexported fields }
LabeledGraph is a graph with vertices of type V and whose edges are labeled with type L.
func New ¶
func New[V comparable, L any](opts ...Opt) *LabeledGraph[V, L]
New returns a new LabeledGraph constructed according to the given options.
func (*LabeledGraph[V, L]) AddEdge ¶
func (g *LabeledGraph[V, L]) AddEdge(u, v V, l L)
AddEdge adds the given edge with the given label to the graph.
func (*LabeledGraph[V, L]) AddVertex ¶
func (g *LabeledGraph[V, L]) AddVertex(v V)
AddVertex adds the given vertex to the graph.
func (*LabeledGraph[V, L]) ContainsEdge ¶
func (g *LabeledGraph[V, L]) ContainsEdge(u, v V) bool
ContainsEdge returns whether the given edge is contained in the graph.
func (*LabeledGraph[V, L]) ContainsVertex ¶
func (g *LabeledGraph[V, L]) ContainsVertex(v V) bool
ContainsVertex returns whether the given vertex is contained in the graph.
func (*LabeledGraph[V, L]) Degree ¶
func (g *LabeledGraph[V, L]) Degree(u V) (int, bool)
Degree return the number of edges coming into or out of the given vertex and true if the vertex exists in the graph. If the given vertex is not in the graph, an empty iterator is returned.
- For directed graphs, Degree is the sum of InDegree and OutDegree.
- For undirected graphs, Degree, InDegree, and OutDegree are all synonymous.
func (*LabeledGraph[V, L]) Directed ¶
func (g *LabeledGraph[V, L]) Directed() bool
Directed returns whether this graph is directed.
func (*LabeledGraph[V, L]) Edges ¶
func (g *LabeledGraph[V, L]) Edges() iter.Seq2[V, V]
Edges returns an iterator over all edges in the graph.
func (*LabeledGraph[V, L]) InDegree ¶
func (g *LabeledGraph[V, L]) InDegree(u V) (int, bool)
InDegree return the number of edges coming into the given vertex and true if the vertex exists in the graph.
func (*LabeledGraph[V, L]) InIncidentEdges ¶
func (g *LabeledGraph[V, L]) InIncidentEdges(v V) iter.Seq2[V, V]
InIncidentEdges returns an iterator over the edges coming into the given vertex of the graph. If the given vertex is not in the graph, an empty iterator is returned.
- For directed graphs, this is the set of edges that terminate at the given vertex.
- For undirected graphs, IncidentEdges, InIncidentEdges, and OutIncidentEdges are all synonymous.
func (*LabeledGraph[V, L]) IncidentEdges ¶
func (g *LabeledGraph[V, L]) IncidentEdges(v V) iter.Seq2[V, V]
IncidentEdges returns all edges that are incident to the given vertex in the graph. If the given vertex is not in the graph, an empty iterator is returned.
- For directed graphs, IncidentEdges is the union of InIncidentEdges and OutIncidentEdges.
- For undirected graphs, IncidentEdges, InIncidentEdges, and OutIncidentEdges are all synonymous.
func (*LabeledGraph[V, L]) Label ¶
func (g *LabeledGraph[V, L]) Label(u, v V) (L, bool)
Label returns the label for edge (u, v) and true if the edge exists in the graph. If no such edge exists, the zero value and false are returned.
func (*LabeledGraph[V, L]) Neighbors ¶
func (g *LabeledGraph[V, L]) Neighbors(v V) iter.Seq[V]
Neighbors is an alias for Successors.
func (*LabeledGraph[V, L]) Order ¶
func (g *LabeledGraph[V, L]) Order() int
Order returns the number of vertices in the graph.
func (*LabeledGraph[V, L]) OutDegree ¶
func (g *LabeledGraph[V, L]) OutDegree(u V) (int, bool)
OutDegree return the number of edges coming out of the given vertex and true if the vertex exists in the graph. If no such vertex exists, the zero value and false are returned.
func (*LabeledGraph[V, L]) OutIncidentEdges ¶
func (g *LabeledGraph[V, L]) OutIncidentEdges(u V) iter.Seq2[V, V]
OutIncidentEdges returns an iterator over the edges coming out of the given vertex of the graph. If the given vertex is not in the graph, an empty iterator is returned.
- For directed graphs, this is the set of edges that originate at the given vertex.
- For undirected graphs, IncidentEdges, InIncidentEdges, and OutIncidentEdges are all synonymous.
func (*LabeledGraph[V, L]) Predecessors ¶
func (g *LabeledGraph[V, L]) Predecessors(v V) iter.Seq[V]
Predecessors returns an iterator over the predecessors of the given vertex in the graph. If the given vertex is not in the graph, an empty iterator is returned.
- For directed graphs, Predecessors is the set of vertices u, such that (u, v) is an edge in the graph for the given vertex v.
- For undirected graphs, Predecessors, Successors, and Neighbors are all synonymous.
func (*LabeledGraph[V, L]) RemoveEdge ¶
func (g *LabeledGraph[V, L]) RemoveEdge(u, v V)
RemoveEdge removes the given edge from the graph.
func (*LabeledGraph[V, L]) RemoveVertex ¶
func (g *LabeledGraph[V, L]) RemoveVertex(v V)
RemoveVertex removes the vertex and all incident edges from the graph.
func (*LabeledGraph[V, L]) SetLabel ¶
func (g *LabeledGraph[V, L]) SetLabel(u, v V, label L)
SetLabel assigns the given label to the given edge in the graph.
func (*LabeledGraph[V, L]) Size ¶
func (g *LabeledGraph[V, L]) Size() int
Size returns the number of edges in the graph.
func (*LabeledGraph[V, L]) Successors ¶
func (g *LabeledGraph[V, L]) Successors(u V) iter.Seq[V]
Successors returns an iterator over the successors of the given vertex in the graph. If the given vertex is not in the graph, an empty iterator is returned.
- For directed graphs, Successors is the set of vertices u, such that (u, v) is an edge in the graph for the given vertex u.
- For undirected graphs, Predecessors, Successors, and Neighbors are all synonymous.
func (*LabeledGraph[V, L]) Vertices ¶
func (g *LabeledGraph[V, L]) Vertices() iter.Seq[V]
Vertices returns an iterator over all vertices in the graph.