Package com.jgalgo.graph
A graph is a collection of vertices (nodes) and edges (links) between them. The edges may be directed or undirected.
The Graph object represent a graph, in which vertices and edges are hashable identifiers.
Vertices can be added or removed to/from a graph, and edges can be added or removed between vertices. The
Graph object also provides methods to query the graph, such as the number of vertices and
edges, and whether a vertex is connected to another vertex, the out-edges or in-edges of a vertex, etc.
Weights can be associated with the vertices or edges of a graph, and the Graph object
provides methods to add or remove weights to it. When a weight is added to the vertices, it is added to all
vertices of the graph. The weights can be an Object or any other primitive such as int,
double, etc. When weights are added to a graph via the
Graph.addVerticesWeights(String, Class) or
Graph.addEdgesWeights(String, Class) methods, a Weights object is
created and return, which allow setting and getting the weights values by vertex/edge identifier. If the weights type
is primitive, a specific subclass of Weights such as WeightsInt,
WeightsDouble, etc. is returned. These specific primitive weights containers avoid the
overhead of boxing and unboxing primitive values.
Each Graph object expose an IndexGraph via the
Graph.indexGraph() method. An index graph is a graph in which the identifiers of the
vertices are always in the range [0, n), where n is the number of vertices in the graph, and the
identifiers of the edges are always in the range [0, m), where m is the number of edges in the graph.
Index graphs are much more efficient than regular graphs, as simple arrays are enough to store the data (internal and
additional weights) associated with the vertices/edges. When a vertex or edge is removed from an index graph, some
identifiers may change, as it must maintain the invariant that the identifiers are always in the range [0, n)
and [0, m). This makes the index graph less convenient to use, but much more efficient. The default graph
implementation uses an index graph internally, and expose it via the Graph.indexGraph()
method. Good written algorithms should accept a regular graph, retrieve its index graph, perform the heavy
computation on the index graph, and translate back the result to the regular graph identifiers. Index graphs should
rarely be used directly by a user.
-
ClassDescriptionAbstractGraph<V,
E> Abstract implementation ofGraph.EdgeIter<V,E> Iterator used to iterate over graph edges.EdgeSet<V,E> Set of graph edges.Graph<V,E> A discrete graph with vertices and edges.GraphBuilder<V,E> A builder for graphs.GraphFactory<V,E> A factory forGraphobjects.Hints for a graph factory.Static methods class for graphs.IdBuilder<K>Builder for unique identifiers of vertices or edges in a graph.Builder for unique identifiers of vertices or edges in anIntGraph.Iterator used to iterate over int graph edges.Set of int graph edges.A graph whose vertices and edges identifiers are indices.A builder for Index graphs.A result object of re-indexing and building a graph operation.A map of indices in range \([0, n)\) to indices in range \([0, n)\).A factory for Index graphs.IndexIdMap<K>A mapping betweenGraphIDs toIndexGraphindices.Static methods class for index-id maps.A mapping betweenIntGraphIDs toIndexGraphindices.A listener that will be notified when anIndexGraphremove a vertex or an edge.A discrete graph withintvertices and edges.A builder for int graphs.A factory forIntGraphobjects.Weight function that maps graph edges or vertices ofIntGraphto weights.Weight function that maps graph edges or vertices ofIntGraphto integer weights.IWeights<T>Weights of int graph vertices or edges.Specific weights ofbooleanfor int graphs.Specific weights ofbytefor int graphs.Specific weights ofcharfor int graphs.Specific weights ofdoublefor int graphs.Specific weights offloatfor int graphs.Specific weights ofintfor int graphs.Specific weights oflongfor int graphs.IWeightsObj<T>Specific weights ofObjectfor int graphs.Specific weights ofshortfor int graphs.Exception thrown when an edge is not found in a graph.Exception thrown when a vertex is not found in a graph.Weight function that maps graph edges or vertices to weights.Weight function that maps graph edges or vertices to integer weights.Static methods class for weight functions.Weights<K,T> Weights of graph vertices or edges.WeightsBool<K>Specific weights ofboolean.WeightsByte<K>Specific weights ofbyte.WeightsChar<K>Specific weights ofchar.Specific weights ofdouble.WeightsFloat<K>Specific weights offloat.WeightsInt<K>Specific weights ofint.WeightsLong<K>Specific weights oflong.WeightsObj<K,T> Specific weights ofObject.WeightsShort<K>Specific weights ofshort.