Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make the "constructor" methods EndpointPair.ordered()/unordered() pub…
…lic (and make the ones accepting a Graph/Network package-private).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131908058
  • Loading branch information
Bezier89 authored and cpovirk committed Sep 1, 2016
1 parent cfe05df commit f7a8a00
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions guava/src/com/google/common/graph/EndpointPair.java
Expand Up @@ -43,28 +43,26 @@ private EndpointPair(N nodeU, N nodeV) {
this.nodeV = checkNotNull(nodeV); this.nodeV = checkNotNull(nodeV);
} }


// TODO(b/31167164): Decide which of these constructors to make public. /** Returns an {@link EndpointPair} representing the endpoints of a directed edge. */
public static <N> EndpointPair<N> ordered(N source, N target) {
return new Ordered<N>(source, target);
}

/** Returns an {@link EndpointPair} representing the endpoints of an undirected edge. */
public static <N> EndpointPair<N> unordered(N nodeU, N nodeV) {
return new Unordered<N>(nodeU, nodeV);
}


/** Returns an {@link EndpointPair} representing the endpoints of an edge in {@code graph}. */ /** Returns an {@link EndpointPair} representing the endpoints of an edge in {@code graph}. */
public static <N> EndpointPair<N> of(Graph<?> graph, N nodeU, N nodeV) { static <N> EndpointPair<N> of(Graph<?> graph, N nodeU, N nodeV) {
return graph.isDirected() ? ordered(nodeU, nodeV) : unordered(nodeU, nodeV); return graph.isDirected() ? ordered(nodeU, nodeV) : unordered(nodeU, nodeV);
} }


/** Returns an {@link EndpointPair} representing the endpoints of an edge in {@code network}. */ /** Returns an {@link EndpointPair} representing the endpoints of an edge in {@code network}. */
public static <N> EndpointPair<N> of(Network<?, ?> network, N nodeU, N nodeV) { static <N> EndpointPair<N> of(Network<?, ?> network, N nodeU, N nodeV) {
return network.isDirected() ? ordered(nodeU, nodeV) : unordered(nodeU, nodeV); return network.isDirected() ? ordered(nodeU, nodeV) : unordered(nodeU, nodeV);
} }


/** Returns an {@link EndpointPair} representing the endpoints of a directed edge. */
static <N> EndpointPair.Ordered<N> ordered(N source, N target) {
return new Ordered<N>(source, target);
}

/** Returns an {@link EndpointPair} representing the endpoints of an undirected edge. */
static <N> EndpointPair.Unordered<N> unordered(N nodeU, N nodeV) {
return new Unordered<N>(nodeU, nodeV);
}

/** /**
* If this {@link EndpointPair} {@link #isOrdered()}, returns the node which is the source. * If this {@link EndpointPair} {@link #isOrdered()}, returns the node which is the source.
* *
Expand Down

0 comments on commit f7a8a00

Please sign in to comment.