-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphFactory.java
59 lines (52 loc) · 1.29 KB
/
GraphFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package vistra.framework.graph;
import vistra.framework.graph.item.ILayoutEdge;
import vistra.framework.graph.item.ILayoutVertex;
import vistra.framework.graph.item.VertexFactory;
import edu.uci.ics.jung.graph.SparseGraph;
import edu.uci.ics.jung.graph.util.EdgeType;
/**
* A graph factory.
*
* @author Roland Bruggmann (brugr9@bfh.ch)
*
*/
public final class GraphFactory {
/**
* A main (no-)constructor.
*/
private GraphFactory() {
}
/**
* Creates an undirected {@code ILayoutGraph}.
*
* @return the graph
*/
public ILayoutGraph create() {
return create(EdgeType.UNDIRECTED);
}
/**
* Creates an {@code ILayoutGraph} with edge type as given based on a JUNG
* {@code SparseGraph}.
*
* @param edgeType
* the edge type
* @return the graph
*/
public static ILayoutGraph create(EdgeType edgeType) {
ILayoutGraph graph = createGraph();
graph.setEdgeType(edgeType);
return graph;
}
/**
* Creates a default JUNG {@code SparseGraph} and extends it to an
* {@code ILayoutGraph}.
*
* @return the graph
*/
private static ILayoutGraph createGraph() {
ILayoutGraph graph = new LayoutGraph(
new SparseGraph<ILayoutVertex, ILayoutEdge>());
VertexFactory.resetSigma();
return graph;
}
}