Class WeightedGraphBuilder<V,W>
java.lang.Object
org.episteme.core.mathematics.discrete.WeightedGraphBuilder<V,W>
Fluent builder for weighted graphs.
Provides a convenient API for constructing weighted graphs:
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Method Summary
Modifier and TypeMethodDescriptionAdds an unweighted edge using the default weight.Adds a weighted edge to the graph.Adds a vertex to the graph.final WeightedGraphBuilder<V, W> addVertices(V... vertices) Adds multiple vertices to the graph.build()Builds and returns the graph.static <V,W> WeightedGraphBuilder <V, W> directed()Creates a builder for a directed weighted graph.static <V,W> WeightedGraphBuilder <V, W> directed(W defaultWeight) Creates a builder for a directed weighted graph with custom default weight.
-
Method Details
-
directed
Creates a builder for a directed weighted graph.- Type Parameters:
V- the type of verticesW- the type of edge weights- Returns:
- a new builder
-
directed
Creates a builder for a directed weighted graph with custom default weight.- Type Parameters:
V- the type of verticesW- the type of edge weights- Parameters:
defaultWeight- the default weight for unweighted edges- Returns:
- a new builder
-
addVertex
Adds a vertex to the graph.- Parameters:
vertex- the vertex to add- Returns:
- this builder for chaining
-
addVertices
Adds multiple vertices to the graph.- Parameters:
vertices- the vertices to add- Returns:
- this builder for chaining
-
addEdge
-
addEdge
Adds an unweighted edge using the default weight.- Parameters:
source- the source vertextarget- the target vertex- Returns:
- this builder for chaining
-
build
Builds and returns the graph.- Returns:
- the constructed weighted graph
-