MCPcopy Create free account
hub / github.com/antlr/codebuff / NetworkBuilder

Class NetworkBuilder

output/java_guava/1.4.17/NetworkBuilder.java:45–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44
45@Beta
46public final class NetworkBuilder<N, E> {
47 final boolean directed;
48 boolean allowsParallelEdges = false;
49 boolean allowsSelfLoops = true;
50
51 Comparator<N> nodeComparator = null;
52
53 Comparator<E> edgeComparator = null;
54
55 Optional<Integer> expectedNodeCount = Optional.absent();
56
57 Optional<Integer> expectedEdgeCount = Optional.absent();
58
59 /**
60 * Creates a new instance with the specified edge directionality.
61 *
62 * @param directed if true, creates an instance for graphs whose edges are each directed;
63 * if false, creates an instance for graphs whose edges are each undirected.
64 */
65
66
67 private NetworkBuilder(boolean directed) {
68 this.directed = directed;
69 }
70
71 /**
72 * Returns a {@link NetworkBuilder} for building directed graphs.
73 */
74
75
76 public static NetworkBuilder<Object, Object> directed() {
77 return new NetworkBuilder<Object, Object>(true);
78 }
79
80 /**
81 * Returns a {@link NetworkBuilder} for building undirected graphs.
82 */
83
84
85 public static NetworkBuilder<Object, Object> undirected() {
86 return new NetworkBuilder<Object, Object>(false);
87 }
88
89 /**
90 * Returns a {@link NetworkBuilder} initialized with all properties queryable from {@code graph}.
91 *
92 * <p>The "queryable" properties are those that are exposed through the {@link Network} interface,
93 * such as {@link Network#isDirected()}. Other properties, such as
94 * {@link #expectedNodeCount(int)}, are not set in the new builder.
95 */
96
97
98 public static <N, E> NetworkBuilder<N, E> from(Network<N, E> graph) {
99 return new NetworkBuilder<N, E>(graph.isDirected()).allowsParallelEdges(graph.allowsParallelEdges()).allowsSelfLoops(graph.allowsSelfLoops());
100 }
101
102 /**

Callers

nothing calls this directly

Calls 1

absentMethod · 0.95

Tested by

no test coverage detected