Skip to content

Commit 1ad9fc0

Browse files
committed
Reversed removal of "Default" prefix and improved documentation
1 parent 611d200 commit 1ad9fc0

File tree

46 files changed

+232
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+232
-384
lines changed

jgrapht-core/src/main/java/org/jgrapht/EdgeFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919

2020
/**
2121
* An edge factory used by graphs for creating new edges.
22+
*
23+
* <p>
24+
* A graph uses the edge factory to create new edge objects whenever a user calls method
25+
* {@link Graph#addEdge(Object, Object)}. Users can also create the edge in user code and then use
26+
* method {@link Graph#addEdge(Object, Object, Object)} to add the edge.
2227
*
28+
* <p>
29+
* Note that when used inside a {@link Graph} the edge factory must return unique objects on each
30+
* call.
31+
*
2332
* @param <V> the graph vertex type
2433
* @param <E> the graph edge type
2534
*

jgrapht-core/src/main/java/org/jgrapht/Graph.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ public interface Graph<V, E>
458458

459459
/**
460460
* Get the graph type. The graph type can be used to query for additional metadata such as
461-
* whether the graph supports directed or undirected edges, self-loops, parallel-edges, weights,
462-
* etc.
461+
* whether the graph supports directed or undirected edges, self-loops, multiple (parallel)
462+
* edges, weights, etc.
463463
*
464464
* @return the graph type
465465
*/

jgrapht-core/src/main/java/org/jgrapht/GraphType.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121
* A graph type.
2222
*
2323
* <p>
24-
* The graph type describes various properties of a graph such as whether it is directed/undirected
25-
* or mixed, whether it contain self-loops (edges with the same source and target vertices), whether
26-
* it contain multiple (parallel) edges (multiple edges with the same source and target) and whether it is
27-
* weighted or not.
24+
* The graph type describes various properties of a graph such as whether it is directed, undirected
25+
* or mixed, whether it contain self-loops (a self-loop is an edge where the source vertex is the
26+
* same as the target vertex), whether it contain multiple (parallel) edges (multiple edges which
27+
* connect the same pair of vertices) and whether it is weighted or not.
28+
*
29+
* <p>
30+
* The type of a graph can be queried on runtime using method {@link Graph#getType()}. This way, for
31+
* example, an algorithm can have different behavior based on whether the input graph is directed or
32+
* undirected, etc.
2833
*
2934
* @author Dimitrios Michail
3035
*/

jgrapht-core/src/main/java/org/jgrapht/graph/ClassBasedEdgeFactory.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
/**
2525
* An {@link EdgeFactory} for producing edges by using a class as a factory.
26+
*
27+
* <p>
28+
* Note that when used inside a {@link Graph} the factory must always return a unique object on each
29+
* call. This implementation calls the no-arguments constructor of the provided class. It is the
30+
* user's responsibility to make sure that the no-arguments constructor creates unique objects.
2631
*
2732
* @param <V> the graph vertex type
2833
* @param <E> the graph edge type
@@ -47,9 +52,6 @@ public ClassBasedEdgeFactory(Class<? extends E> edgeClass)
4752
this.edgeClass = edgeClass;
4853
}
4954

50-
/**
51-
* @see EdgeFactory#createEdge(Object, Object)
52-
*/
5355
@Override
5456
public E createEdge(V source, V target)
5557
{

jgrapht-core/src/main/java/org/jgrapht/graph/DefaultDirectedGraph.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@
2121
import org.jgrapht.graph.builder.*;
2222

2323
/**
24-
* A directed graph. A default directed graph is a non-simple directed graph in which multiple (parallel) edges
25-
* between any two vertices are <i>not</i> permitted, but loops are.
26-
*
27-
* <p>
28-
* prefixed 'Default' to avoid name collision with the DirectedGraph interface.
29-
* </p>
24+
* The default implementation of a directed graph. A default directed graph is a non-simple directed
25+
* graph in which multiple (parallel) edges between any two vertices are <i>not</i> permitted, but
26+
* loops are.
3027
*
3128
* @param <V> the graph vertex type
3229
* @param <E> the graph edge type
3330
*
34-
* @deprecated In favor of {@link DirectedGraph}
3531
*/
36-
@Deprecated
3732
public class DefaultDirectedGraph<V, E>
3833
extends AbstractBaseGraph<V, E>
3934
{

jgrapht-core/src/main/java/org/jgrapht/graph/DefaultDirectedWeightedGraph.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@
2121
import org.jgrapht.graph.builder.*;
2222

2323
/**
24-
* A directed weighted graph. A directed weighted graph is a non-simple directed graph in which
25-
* multiple (parallel) edges between any two vertices are <i>not</i> permitted, but loops are. The graph has
26-
* weights on its edges.
24+
* The default implementation of a directed weighted graph. A default directed weighted graph is a
25+
* non-simple directed graph in which multiple (parallel) edges between any two vertices are
26+
* <i>not</i> permitted, but loops are. The graph has weights on its edges.
2727
*
2828
* @param <V> the graph vertex type
2929
* @param <E> the graph edge type
3030
*
3131
* @see DefaultDirectedGraph
32-
* @deprecated In favor of {@link DirectedWeightedGraph}
3332
*/
34-
@Deprecated
3533
public class DefaultDirectedWeightedGraph<V, E>
3634
extends DefaultDirectedGraph<V, E>
3735
{

jgrapht-core/src/main/java/org/jgrapht/graph/DefaultGraphType.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@
2626
*
2727
* <p>
2828
* The graph type describes various properties of a graph such as whether it is directed, undirected
29-
* or mixed, whether it contain self-loops (edges with the same source and target vertices), whether
30-
* it contain multiple (parallel) edges (edges with the same source and target) and whether it is
31-
* weighted or not.
29+
* or mixed, whether it contain self-loops (a self-loop is an edge where the source vertex is the
30+
* same as the target vertex), whether it contain multiple (parallel) edges (multiple edges which
31+
* connect the same pair of vertices) and whether it is weighted or not.
32+
*
33+
* <p>
34+
* The type of a graph can be queried on runtime using method {@link Graph#getType()}. This way, for
35+
* example, an algorithm can have different behavior based on whether the input graph is directed or
36+
* undirected, etc.
3237
*
3338
* @author Dimitrios Michail
3439
*/
3540
public class DefaultGraphType
36-
implements
37-
GraphType,
38-
Serializable
41+
implements GraphType, Serializable
3942
{
4043
private static final long serialVersionUID = 4291049312119347474L;
4144

jgrapht-core/src/main/java/org/jgrapht/graph/UndirectedGraph.java renamed to jgrapht-core/src/main/java/org/jgrapht/graph/DefaultUndirectedGraph.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
import org.jgrapht.graph.builder.*;
2222

2323
/**
24-
* An undirected graph. An undirected graph is a non-simple undirected graph in which multiple (parallel) edges
25-
* between any two vertices are <i>not</i> permitted, but loops are.
24+
* The default implementation of an undirected graph. A default undirected graph is a non-simple
25+
* undirected graph in which multiple (parallel) edges between any two vertices are <i>not</i>
26+
* permitted, but loops are.
2627
*
2728
* @param <V> the graph vertex type
2829
* @param <E> the graph edge type
2930
*/
30-
public class UndirectedGraph<V, E>
31+
public class DefaultUndirectedGraph<V, E>
3132
extends AbstractBaseGraph<V, E>
3233
{
3334
private static final long serialVersionUID = -2066644490824847621L;
@@ -37,7 +38,7 @@ public class UndirectedGraph<V, E>
3738
*
3839
* @param edgeClass class on which to base factory for edges
3940
*/
40-
public UndirectedGraph(Class<? extends E> edgeClass)
41+
public DefaultUndirectedGraph(Class<? extends E> edgeClass)
4142
{
4243
this(new ClassBasedEdgeFactory<>(edgeClass));
4344
}
@@ -47,7 +48,7 @@ public UndirectedGraph(Class<? extends E> edgeClass)
4748
*
4849
* @param ef the edge factory of the new graph.
4950
*/
50-
public UndirectedGraph(EdgeFactory<V, E> ef)
51+
public DefaultUndirectedGraph(EdgeFactory<V, E> ef)
5152
{
5253
this(ef, false);
5354
}
@@ -58,7 +59,7 @@ public UndirectedGraph(EdgeFactory<V, E> ef)
5859
* @param weighted if true the graph supports edge weights
5960
* @param ef the edge factory of the new graph.
6061
*/
61-
public UndirectedGraph(EdgeFactory<V, E> ef, boolean weighted)
62+
public DefaultUndirectedGraph(EdgeFactory<V, E> ef, boolean weighted)
6263
{
6364
super(ef, false, false, true, weighted);
6465
}
@@ -71,10 +72,10 @@ public UndirectedGraph(EdgeFactory<V, E> ef, boolean weighted)
7172
* @param <E> the graph edge type
7273
* @return a builder for this kind of graph
7374
*/
74-
public static <V, E> GraphBuilder<V, E, ? extends UndirectedGraph<V, E>> createBuilder(
75+
public static <V, E> GraphBuilder<V, E, ? extends DefaultUndirectedGraph<V, E>> createBuilder(
7576
Class<? extends E> edgeClass)
7677
{
77-
return new GraphBuilder<>(new UndirectedGraph<>(edgeClass));
78+
return new GraphBuilder<>(new DefaultUndirectedGraph<>(edgeClass));
7879
}
7980

8081
/**
@@ -85,10 +86,10 @@ public UndirectedGraph(EdgeFactory<V, E> ef, boolean weighted)
8586
* @param <E> the graph edge type
8687
* @return a builder for this kind of graph
8788
*/
88-
public static <V,
89-
E> GraphBuilder<V, E, ? extends UndirectedGraph<V, E>> createBuilder(EdgeFactory<V, E> ef)
89+
public static <V, E> GraphBuilder<V, E, ? extends DefaultUndirectedGraph<V, E>> createBuilder(
90+
EdgeFactory<V, E> ef)
9091
{
91-
return new GraphBuilder<>(new UndirectedGraph<>(ef));
92+
return new GraphBuilder<>(new DefaultUndirectedGraph<>(ef));
9293
}
9394
}
9495

jgrapht-core/src/main/java/org/jgrapht/graph/UndirectedWeightedGraph.java renamed to jgrapht-core/src/main/java/org/jgrapht/graph/DefaultUndirectedWeightedGraph.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
import org.jgrapht.graph.builder.*;
2222

2323
/**
24-
* A undirected weighted graph. An undirected weighted graph is a non-simple undirected graph in
25-
* which multiple (parallel) edges between any two vertices are <i>not</i> permitted, but loops are. The edges
26-
* of a weighted undirected graph have weights.
24+
* The default implementation of an undirected weighted graph. A default undirected weighted graph
25+
* is a non-simple undirected graph in which multiple (parallel) edges between any two vertices are
26+
* <i>not</i> permitted, but loops are. The edges of a weighted undirected graph have weights.
2727
*
2828
* @param <V> the graph vertex type
2929
* @param <E> the graph edge type
30+
*
31+
* @see DefaultUndirectedGraph
3032
*/
31-
public class UndirectedWeightedGraph<V, E>
32-
extends UndirectedGraph<V, E>
33+
public class DefaultUndirectedWeightedGraph<V, E>
34+
extends DefaultUndirectedGraph<V, E>
3335
{
3436
private static final long serialVersionUID = -1008165881690129042L;
3537

@@ -38,7 +40,7 @@ public class UndirectedWeightedGraph<V, E>
3840
*
3941
* @param ef the edge factory of the new graph.
4042
*/
41-
public UndirectedWeightedGraph(EdgeFactory<V, E> ef)
43+
public DefaultUndirectedWeightedGraph(EdgeFactory<V, E> ef)
4244
{
4345
super(ef, true);
4446
}
@@ -48,7 +50,7 @@ public UndirectedWeightedGraph(EdgeFactory<V, E> ef)
4850
*
4951
* @param edgeClass class on which to base factory for edges
5052
*/
51-
public UndirectedWeightedGraph(Class<? extends E> edgeClass)
53+
public DefaultUndirectedWeightedGraph(Class<? extends E> edgeClass)
5254
{
5355
this(new ClassBasedEdgeFactory<>(edgeClass));
5456
}
@@ -61,10 +63,11 @@ public UndirectedWeightedGraph(Class<? extends E> edgeClass)
6163
* @param <E> the graph edge type
6264
* @return a builder for this kind of graph
6365
*/
64-
public static <V, E> GraphBuilder<V, E, ? extends UndirectedWeightedGraph<V, E>> createBuilder(
65-
Class<? extends E> edgeClass)
66+
public static <V,
67+
E> GraphBuilder<V, E, ? extends DefaultUndirectedWeightedGraph<V, E>> createBuilder(
68+
Class<? extends E> edgeClass)
6669
{
67-
return new GraphBuilder<>(new UndirectedWeightedGraph<>(edgeClass));
70+
return new GraphBuilder<>(new DefaultUndirectedWeightedGraph<>(edgeClass));
6871
}
6972

7073
/**
@@ -75,9 +78,10 @@ public UndirectedWeightedGraph(Class<? extends E> edgeClass)
7578
* @param <E> the graph edge type
7679
* @return a builder for this kind of graph
7780
*/
78-
public static <V, E> GraphBuilder<V, E, ? extends UndirectedWeightedGraph<V, E>> createBuilder(
79-
EdgeFactory<V, E> ef)
81+
public static <V,
82+
E> GraphBuilder<V, E, ? extends DefaultUndirectedWeightedGraph<V, E>> createBuilder(
83+
EdgeFactory<V, E> ef)
8084
{
81-
return new GraphBuilder<>(new UndirectedWeightedGraph<>(ef));
85+
return new GraphBuilder<>(new DefaultUndirectedWeightedGraph<>(ef));
8286
}
8387
}

jgrapht-core/src/main/java/org/jgrapht/graph/DirectedGraph.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)