Example usage for com.google.common.graph Network edgesConnecting

List of usage examples for com.google.common.graph Network edgesConnecting

Introduction

In this page you can find the example usage for com.google.common.graph Network edgesConnecting.

Prototype

Set<E> edgesConnecting(Object node1, Object node2);

Source Link

Document

Returns the set of edges that connect node1 to node2 .

Usage

From source file:edu.uci.ics.jung.visualization.util.ParallelEdgeIndexFunction.java

public int getIndex(Context<Network<N, E>, E> context) {
    Network<N, E> network = context.graph;
    E edge = context.element;/*from  w w  w. j  a va2  s . com*/
    Integer index = edge_index.get(edge);
    if (index == null) {
        EndpointPair<N> endpoints = network.incidentNodes(edge);
        N u = endpoints.nodeU();
        N v = endpoints.nodeV();
        int count = 0;
        for (E connectingEdge : network.edgesConnecting(u, v)) {
            edge_index.put(connectingEdge, count++);
        }
        return edge_index.get(edge);
    }
    return index;
}

From source file:org.apache.beam.runners.dataflow.worker.IntrinsicMapTaskExecutorFactory.java

private OperationNode createParDoOperation(Network<Node, Edge> network, ParallelInstructionNode node,
        PipelineOptions options, DataflowExecutionContext<?> executionContext,
        DataflowOperationContext operationContext) throws Exception {

    ParallelInstruction instruction = node.getParallelInstruction();
    ParDoInstruction parDo = instruction.getParDo();

    TupleTag<?> mainOutputTag = tupleTag(parDo.getMultiOutputInfos().get(0));
    ImmutableMap.Builder<TupleTag<?>, Integer> outputTagsToReceiverIndicesBuilder = ImmutableMap.builder();
    int successorOffset = 0;
    for (Node successor : network.successors(node)) {
        for (Edge edge : network.edgesConnecting(node, successor)) {
            outputTagsToReceiverIndicesBuilder.put(tupleTag(((MultiOutputInfoEdge) edge).getMultiOutputInfo()),
                    successorOffset);/*  w ww.j a v  a 2  s.  c om*/
        }
        successorOffset += 1;
    }
    ParDoFn fn = parDoFnFactory.create(options, CloudObject.fromSpec(parDo.getUserFn()), parDo.getSideInputs(),
            mainOutputTag, outputTagsToReceiverIndicesBuilder.build(), executionContext, operationContext);

    OutputReceiver[] receivers = getOutputReceivers(network, node);
    return OperationNode.create(new ParDoOperation(fn, receivers, operationContext));
}