Documentation
¶
Index ¶
- type Config
- type Graph
- func (g Graph[V]) AddEdge(u, v V)
- func (g Graph[V]) AddVertex(v V)
- func (g Graph[V]) ContainsEdge(u, v V) bool
- func (g Graph[V]) ContainsVertex(v V) bool
- func (g Graph[V]) Degree(u V) (int, bool)
- func (g Graph[V]) Directed() bool
- func (g Graph[V]) Edges() iter.Seq2[V, V]
- func (g Graph[V]) InDegree(u V) (int, bool)
- func (g Graph[V]) InIncidentEdges(v V) iter.Seq2[V, V]
- func (g Graph[V]) IncidentEdges(v V) iter.Seq2[V, V]
- func (g Graph[V]) Neighbors(v V) iter.Seq[V]
- func (g Graph[V]) Order() int
- func (g Graph[V]) OutDegree(u V) (int, bool)
- func (g Graph[V]) OutIncidentEdges(u V) iter.Seq2[V, V]
- func (g Graph[V]) Predecessors(v V) iter.Seq[V]
- func (g Graph[V]) RemoveEdge(u, v V)
- func (g Graph[V]) RemoveVertex(v V)
- func (g Graph[V]) Size() int
- func (g Graph[V]) Successors(u V) iter.Seq[V]
- func (g Graph[V]) 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 Graph ¶
type Graph[V comparable] struct { // contains filtered or unexported fields }
Graph is a graph with vertices of type V.
func New ¶
func New[V comparable](opts ...Opt) *Graph[V]
New returns a new LabeledGraph constructed according to the given options.
func (Graph[V]) AddEdge ¶
func (g Graph[V]) AddEdge(u, v V)
AddEdge adds the given edge with the given label to the graph.
func (Graph[V]) AddVertex ¶
func (g Graph[V]) AddVertex(v V)
AddVertex adds the given vertex to the graph.
func (Graph[V]) ContainsEdge ¶
ContainsEdge returns whether the given edge is contained in the graph.
func (Graph[V]) ContainsVertex ¶
ContainsVertex returns whether the given vertex is contained in the graph.
func (Graph[V]) Degree ¶
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 (Graph[V]) InDegree ¶
InDegree return the number of edges coming into the given vertex and true if the vertex exists in the graph.
func (Graph[V]) InIncidentEdges ¶
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 (Graph[V]) IncidentEdges ¶
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 (Graph[V]) OutDegree ¶
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 (Graph[V]) OutIncidentEdges ¶
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 (Graph[V]) Predecessors ¶
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 (Graph[V]) RemoveEdge ¶
func (g Graph[V]) RemoveEdge(u, v V)
RemoveEdge removes the given edge from the graph.
func (Graph[V]) RemoveVertex ¶
func (g Graph[V]) RemoveVertex(v V)
RemoveVertex removes the vertex and all incident edges from the graph.
func (Graph[V]) Successors ¶
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.