private static <N, V> Map<EndpointPair<N>, V> edgeValueMap(final ValueGraph<N, V> graph) { Function<EndpointPair<N>, V> edgeToValueFn = new Function<EndpointPair<N>, V>() { @Override public V apply(EndpointPair<N> edge) { return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null); } }; return Maps.asMap(graph.edges(), edgeToValueFn); } }
/** * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full * edges() implementation. */ @Override protected long edgeCount() { return delegate().edges().size(); }
private static <N, V> Map<EndpointPair<N>, V> edgeValueMap(final ValueGraph<N, V> graph) { Function<EndpointPair<N>, V> edgeToValueFn = new Function<EndpointPair<N>, V>() { @Override public V apply(EndpointPair<N> edge) { return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null); } }; return Maps.asMap(graph.edges(), edgeToValueFn); } }
/** * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full * edges() implementation. */ @Override protected long edgeCount() { return delegate().edges().size(); }
private ImmutableValueGraph(ValueGraph<N, V> graph) { super(ValueGraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()); }
/** * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full * edges() implementation. */ @Override protected long edgeCount() { return delegate().edges().size(); }
private static <N, V> Map<EndpointPair<N>, V> edgeValueMap(final ValueGraph<N, V> graph) { Function<EndpointPair<N>, V> edgeToValueFn = new Function<EndpointPair<N>, V>() { @Override public V apply(EndpointPair<N> edge) { return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null); } }; return Maps.asMap(graph.edges(), edgeToValueFn); } }
private ImmutableValueGraph(ValueGraph<N, V> graph) { super(ValueGraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()); }
private ImmutableValueGraph(ValueGraph<N, V> graph) { super(ValueGraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()); }
/** Creates a mutable copy of {@code graph} with the same nodes, edges, and edge values. */ public static <N, V> MutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph) { MutableValueGraph<N, V> copy = ValueGraphBuilder.from(graph).expectedNodeCount(graph.nodes().size()).build(); for (N node : graph.nodes()) { copy.addNode(node); } for (EndpointPair<N> edge : graph.edges()) { copy.putEdgeValue( edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null)); } return copy; }
/** Creates a mutable copy of {@code network} with the same nodes and edges. */ public static <N, E> MutableNetwork<N, E> copyOf(Network<N, E> network) { MutableNetwork<N, E> copy = NetworkBuilder.from(network) .expectedNodeCount(network.nodes().size()) .expectedEdgeCount(network.edges().size()) .build(); for (N node : network.nodes()) { copy.addNode(node); } for (E edge : network.edges()) { EndpointPair<N> endpointPair = network.incidentNodes(edge); copy.addEdge(endpointPair.nodeU(), endpointPair.nodeV(), edge); } return copy; }
/** Creates a mutable copy of {@code graph} with the same nodes, edges, and edge values. */ public static <N, V> MutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph) { MutableValueGraph<N, V> copy = ValueGraphBuilder.from(graph).expectedNodeCount(graph.nodes().size()).build(); for (N node : graph.nodes()) { copy.addNode(node); } for (EndpointPair<N> edge : graph.edges()) { copy.putEdgeValue( edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null)); } return copy; }
@Override public boolean containsEdge(EndpointPair<V> e) { return valueGraph.edges().contains(e); }
@Override public Set<EndpointPair<V>> edgeSet() { if (unmodifiableEdgeSet == null) { unmodifiableEdgeSet = Collections.unmodifiableSet(valueGraph.edges()); } return unmodifiableEdgeSet; }
private static <N, V> Map<EndpointPair<N>, V> edgeValueMap(final ValueGraph<N, V> graph) { Function<EndpointPair<N>, V> edgeToValueFn = new Function<EndpointPair<N>, V>() { @Override public V apply(EndpointPair<N> edge) { return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null); } }; return Maps.asMap(graph.edges(), edgeToValueFn); } }
/** * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full * edges() implementation. */ @Override protected long edgeCount() { return delegate().edges().size(); }
/** * Defer to {@link AbstractValueGraph#edges()} (based on {@link #successors(Object)}) for full * edges() implementation. */ @Override protected long edgeCount() { return delegate().edges().size(); }
private static <N, V> Map<EndpointPair<N>, V> edgeValueMap(final ValueGraph<N, V> graph) { Function<EndpointPair<N>, V> edgeToValueFn = new Function<EndpointPair<N>, V>() { @Override public V apply(EndpointPair<N> edge) { return graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null); } }; return Maps.asMap(graph.edges(), edgeToValueFn); } }
private ImmutableValueGraph(ValueGraph<N, V> graph) { super(ValueGraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()); }
/** Creates a mutable copy of {@code graph} with the same nodes, edges, and edge values. */ public static <N, V> MutableValueGraph<N, V> copyOf(ValueGraph<N, V> graph) { MutableValueGraph<N, V> copy = ValueGraphBuilder.from(graph).expectedNodeCount(graph.nodes().size()).build(); for (N node : graph.nodes()) { copy.addNode(node); } for (EndpointPair<N> edge : graph.edges()) { copy.putEdgeValue( edge.nodeU(), edge.nodeV(), graph.edgeValueOrDefault(edge.nodeU(), edge.nodeV(), null)); } return copy; }