Append Inception-ResNet C to a computation graph.
@param graph
@param blockName
@param scale
@param activationScale
@param input
@return
508951
public static ComputationGraphConfiguration.GraphBuilder inceptionV1ResC(
                    ComputationGraphConfiguration.GraphBuilder graph, String blockName, int scale,
                    double activationScale, String input) {
        // loop and add each subsequent resnet blocks
        String previousBlock = input;
        for (int i = 1; i <= scale; i++) {
            graph
                            // 1x1
                            .addLayer(nameLayer(blockName, "cnn1", i),
                                            new ConvolutionLayer.Builder(new int[] {1, 1})
                                                            .convolutionMode(ConvolutionMode.Same).nIn(1344).nOut(192)
                                                            .cudnnAlgoMode(ConvolutionLayer.AlgoMode.NO_WORKSPACE)
                                                            .build(),
                                            previousBlock)
                            .addLayer(nameLayer(blockName, "batch1", i),
                                            new BatchNormalization.Builder(false).decay(0.995).eps(0.001).nIn(192)
                                                            .nOut(192).build(),
                                            nameLayer(blockName, "cnn1", i))
                            // 1x1 -> 1x3 -> 3x1
                            .addLayer(nameLayer(blockName, "cnn2", i),
                                            new ConvolutionLayer.Builder(new int[] {1, 1})
                                                            .convolutionMode(ConvolutionMode.Same).nIn(1344).nOut(192)
                                                            .cudnnAlgoMode(ConvolutionLayer.AlgoMode.NO_WORKSPACE)
                                                            .build(),
                                            previousBlock)
                            .addLayer(nameLayer(blockName, "batch2", i),
                                            new BatchNormalization.Builder(false).decay(0.995).eps(0.001).nIn(192)
                                                            .nOut(192).build(),
                                            nameLayer(blockName, "cnn2", i))
                            .addLayer(nameLayer(blockName, "cnn3", i),
                                            new ConvolutionLayer.Builder(new int[] {1, 3})
                                                            .convolutionMode(ConvolutionMode.Same).nIn(192).nOut(192)
                                                            .cudnnAlgoMode(ConvolutionLayer.AlgoMode.NO_WORKSPACE)
                                                            .build(),
                                            nameLayer(blockName, "batch2", i))
                            .addLayer(nameLayer(blockName, "batch3", i),
                                            new BatchNormalization.Builder(false).decay(0.995).eps(0.001).nIn(192)
                                                            .nOut(192).build(),
                                            nameLayer(blockName, "cnn3", i))
                            .addLayer(nameLayer(blockName, "cnn4", i),
                                            new ConvolutionLayer.Builder(new int[] {3, 1})
                                                            .convolutionMode(ConvolutionMode.Same).nIn(192).nOut(192)
                                                            .cudnnAlgoMode(ConvolutionLayer.AlgoMode.NO_WORKSPACE)
                                                            .build(),
                                            nameLayer(blockName, "batch3", i))
                            .addLayer(nameLayer(blockName, "batch4", i),
                                            new BatchNormalization.Builder(false).decay(0.995).eps(0.001)
                                                            .activation(Activation.TANH).nIn(192).nOut(192).build(),
                                            nameLayer(blockName, "cnn4", i))
                            // --> 1x1 --> scale -->
                            .addVertex(nameLayer(blockName, "merge1", i), new MergeVertex(),
                                            nameLayer(blockName, "batch1", i), nameLayer(blockName, "batch4", i))
                            .addLayer(nameLayer(blockName, "cnn5", i),
                                            new ConvolutionLayer.Builder(new int[] {1, 1})
                                                            .convolutionMode(ConvolutionMode.Same).nIn(384).nOut(1344)
                                                            .cudnnAlgoMode(ConvolutionLayer.AlgoMode.NO_WORKSPACE)
                                                            .build(),
                                            nameLayer(blockName, "merge1", i))
                            .addLayer(nameLayer(blockName, "batch5", i),
                                            new BatchNormalization.Builder(false).decay(0.995).eps(0.001)
                                                            .activation(Activation.TANH).nIn(1344).nOut(1344).build(),
                                            nameLayer(blockName, "cnn5", i))
                            .addVertex(nameLayer(blockName, "scaling", i), new ScaleVertex(activationScale),
                                            nameLayer(blockName, "batch5", i))
                            // -->
                            .addLayer(nameLayer(blockName, "shortcut-identity", i),
                                            new ActivationLayer.Builder().activation(Activation.IDENTITY).build(),
                                            previousBlock)
                            .addVertex(nameLayer(blockName, "shortcut", i),
                                            new ElementWiseVertex(ElementWiseVertex.Op.Add),
                                            nameLayer(blockName, "scaling", i),
                                            nameLayer(blockName, "shortcut-identity", i));

            // leave the last vertex as the block name for convenience
            if (i == scale)
                graph.addLayer(blockName, new ActivationLayer.Builder().activation(Activation.TANH).build(),
                                nameLayer(blockName, "shortcut", i));
            else
                graph.addLayer(nameLayer(blockName, "activation", i),
                                new ActivationLayer.Builder().activation(Activation.TANH).build(),
                                nameLayer(blockName, "shortcut", i));

            previousBlock = nameLayer(blockName, "activation", i);
        }
        return graph;
    }
783575
def block_to_graphviz_string(block=None, namer=_graphviz_default_namer):
    
    graph = net_graph(block, split_state=True)
    node_index_map = {}  # map node -> index

    rstring = """\
              digraph g {\n
              graph [splines="spline"];
              node [shape=circle, style=filled, fillcolor=lightblue1,
                    fontcolor=grey, fontname=helvetica, penwidth=0,
                    fixedsize=true];
              edge [labelfloat=false, penwidth=2, color=deepskyblue, arrowsize=.5];
              """

    # print the list of nodes
    for index, node in enumerate(graph):
        label = namer(node, is_edge=False)
        rstring += '    n%s %s;\n' % (index, label)
        node_index_map[node] = index

    # print the list of edges
    for _from in graph:
        for _to in graph[_from]:
            from_index = node_index_map[_from]
            to_index = node_index_map[_to]
            edge = graph[_from][_to]
            is_to_splitmerge = True if hasattr(_to, 'op') and _to.op in 'cs' else False
            label = namer(edge, is_to_splitmerge=is_to_splitmerge)
            rstring += '   n%d -> n%d %s;\n' % (from_index, to_index, label)

    rstring += '}\n'
    return rstring
110269
public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
    final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
    final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());

    while (!unmarkedNodes.isEmpty()) {
      Set<Node<T>> connectedComp = new LinkedHashSet<>();
      deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
      connectedComponents.add(connectedComp);
    }

    return connectedComponents;
  }
1019817
def create_copy_without_data(G):
    """"""
    H = nx.Graph()
    for i in H.nodes_iter():
        H.node[i] = {}
    return H
1233920
private void initHelperGraph() {

        int[] backPropOrder = origGraph.topologicalSortOrder().clone();
        ArrayUtils.reverse(backPropOrder);

        Set<String> allFrozen = new HashSet<>();
        if (applyFrozen) {
            Collections.addAll(allFrozen, frozenOutputAt);
        }
        for (int i = 0; i < backPropOrder.length; i++) {
            org.deeplearning4j.nn.graph.vertex.GraphVertex gv = origGraph.getVertices()[backPropOrder[i]];
            if (applyFrozen && allFrozen.contains(gv.getVertexName())) {
                if (gv.hasLayer()) {
                    //Need to freeze this layer
                    org.deeplearning4j.nn.api.Layer l = gv.getLayer();
                    gv.setLayerAsFrozen();

                    //We also need to place the layer in the CompGraph Layer[] (replacing the old one)
                    //This could no doubt be done more efficiently
                    org.deeplearning4j.nn.api.Layer[] layers = origGraph.getLayers();
                    for (int j = 0; j < layers.length; j++) {
                        if (layers[j] == l) {
                            layers[j] = gv.getLayer(); //Place the new frozen layer to replace the original layer
                            break;
                        }
                    }
                }

                //Also: mark any inputs as to be frozen also
                VertexIndices[] inputs = gv.getInputVertices();
                if (inputs != null && inputs.length > 0) {
                    for (int j = 0; j < inputs.length; j++) {
                        int inputVertexIdx = inputs[j].getVertexIndex();
                        String alsoFreeze = origGraph.getVertices()[inputVertexIdx].getVertexName();
                        allFrozen.add(alsoFreeze);
                    }
                }
            } else {
                if (gv.hasLayer()) {
                    if (gv.getLayer() instanceof FrozenLayer) {
                        allFrozen.add(gv.getVertexName());
                        //also need to add parents to list of allFrozen
                        VertexIndices[] inputs = gv.getInputVertices();
                        if (inputs != null && inputs.length > 0) {
                            for (int j = 0; j < inputs.length; j++) {
                                int inputVertexIdx = inputs[j].getVertexIndex();
                                String alsoFrozen = origGraph.getVertices()[inputVertexIdx].getVertexName();
                                allFrozen.add(alsoFrozen);
                            }
                        }
                    }
                }
            }
        }
        for (int i = 0; i < backPropOrder.length; i++) {
            org.deeplearning4j.nn.graph.vertex.GraphVertex gv = origGraph.getVertices()[backPropOrder[i]];
            String gvName = gv.getVertexName();
            //is it an unfrozen vertex that has an input vertex that is frozen?
            if (!allFrozen.contains(gvName) && !gv.isInputVertex()) {
                VertexIndices[] inputs = gv.getInputVertices();
                for (int j = 0; j < inputs.length; j++) {
                    int inputVertexIdx = inputs[j].getVertexIndex();
                    String inputVertex = origGraph.getVertices()[inputVertexIdx].getVertexName();
                    if (allFrozen.contains(inputVertex)) {
                        frozenInputVertices.add(inputVertex);
                    }
                }
            }
        }

        TransferLearning.GraphBuilder builder = new TransferLearning.GraphBuilder(origGraph);
        for (String toRemove : allFrozen) {
            if (frozenInputVertices.contains(toRemove)) {
                builder.removeVertexKeepConnections(toRemove);
            } else {
                builder.removeVertexAndConnections(toRemove);
            }
        }

        Set<String> frozenInputVerticesSorted = new HashSet<>();
        frozenInputVerticesSorted.addAll(origGraph.getConfiguration().getNetworkInputs());
        frozenInputVerticesSorted.removeAll(allFrozen);
        //remove input vertices - just to add back in a predictable order
        for (String existingInput : frozenInputVerticesSorted) {
            builder.removeVertexKeepConnections(existingInput);
        }
        frozenInputVerticesSorted.addAll(frozenInputVertices);
        //Sort all inputs to the computation graph - in order to have a predictable order
        graphInputs = new ArrayList(frozenInputVerticesSorted);
        Collections.sort(graphInputs);
        for (String asInput : frozenInputVerticesSorted) {
            //add back in the right order
            builder.addInputs(asInput);
        }
        unFrozenSubsetGraph = builder.build();
        copyOrigParamsToSubsetGraph();
        //unFrozenSubsetGraph.setListeners(origGraph.getListeners());

        if (frozenInputVertices.isEmpty()) {
            throw new IllegalArgumentException("No frozen layers found");
        }

    }
11214
def block17(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):
  """"""
  with tf.variable_scope(scope, 'Block17', [net], reuse=reuse):
    with tf.variable_scope('Branch_0'):
      tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')
    with tf.variable_scope('Branch_1'):
      tower_conv1_0 = slim.conv2d(net, 128, 1, scope='Conv2d_0a_1x1')
      tower_conv1_1 = slim.conv2d(tower_conv1_0, 160, [1, 7],
                                  scope='Conv2d_0b_1x7')
      tower_conv1_2 = slim.conv2d(tower_conv1_1, 192, [7, 1],
                                  scope='Conv2d_0c_7x1')
    mixed = tf.concat(axis=3, values=[tower_conv, tower_conv1_2])
    up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,
                     activation_fn=None, scope='Conv2d_1x1')
    net += scale * up
    if activation_fn:
      net = activation_fn(net)
  return net
285258
public long compute(java.util.Vector<Long> e, java.util.Vector<java.util.List<Edge>> c, java.util.Vector<java.util.List<EdgeFlow>> x) {
        assert e.size() == c.size();
        assert x.size() == c.size();

        numNodes = e.size();
        nodesToQ = new java.util.Vector<Integer>();
        for (int i = 0; i < numNodes; i++) {
            nodesToQ.add(0);
        }

        // init flow
        for (int from = 0; from < numNodes; ++from) {
            for (Edge it : c.get(from)) {
                x.get(from).add(new EdgeFlow(it.getTo(), it.getCost(), 0));
                x.get(it.getTo()).add(new EdgeFlow(from, -it.getCost(), 0));
            }
        }

        // reduced costs for forward edges (c[i,j]-pi[i]+pi[j])
        // Note that for forward edges the residual capacity is infinity
        java.util.Vector<java.util.List<ReducedEdge>> rCostForward = new java.util.Vector<java.util.List<ReducedEdge>>();
        for (int i = 0; i < numNodes; i++) {
            rCostForward.add(new java.util.LinkedList<ReducedEdge>());
        }
        for (int from = 0; from < numNodes; ++from) {
            for (Edge it : c.get(from)) {
                rCostForward.get(from).add(new ReducedEdge(it.getTo(), it.getCost()));
            }
        }

        // reduced costs and capacity for backward edges
        // (c[j,i]-pi[j]+pi[i])
        // Since the flow at the beginning is 0, the residual capacity is
        // also zero
        java.util.Vector<java.util.List<ResidualReducedEdge>> rCostCapBackward = new java.util.Vector<java.util.List<ResidualReducedEdge>>();
        for (int i = 0; i < numNodes; i++) {
            rCostCapBackward.add(new java.util.LinkedList<ResidualReducedEdge>());
        }
        for (int from = 0; from < numNodes; ++from) {
            for (Edge it : c.get(from)) {
                rCostCapBackward.get(it.getTo()).add(
                        new ResidualReducedEdge(from, -it.getCost(), 0));
            }
        }

        // Max supply TODO:demand?, given U?, optimization-> min out of
        // demand,supply
        long u = 0;
        for (int i = 0; i < numNodes; i++) {
            if (e.get(i) > u) {
                u = e.get(i);
            }
        }
        //long delta = (long) (Math.pow(2.0, Math.ceil(Math.log((double) U) / Math.log(2.0))));

        java.util.Vector<Long> d = new java.util.Vector<Long>();
        java.util.Vector<Integer> prev = new java.util.Vector<Integer>();
        for (int i = 0; i < numNodes; i++) {
            d.add(0L);
            prev.add(0);
        }
        long delta = 1;
        long tmp;
        while (true) { // until we break when S or T is empty
            long maxSupply = 0;
            int k = 0;
            for (int i = 0; i < numNodes; i++) {
                if (e.get(i) > 0) {
                    if (maxSupply < e.get(i)) {
                        maxSupply = e.get(i);
                        k = i;
                    }
                }
            }
            if (maxSupply == 0) {
                break;
            }
            delta = maxSupply;

            int[] l = new int[1];
            computeShortestPath(d, prev, k, rCostForward, rCostCapBackward,
                    e, l);

            // find delta (minimum on the path from k to l)
            // delta= e[k];
            // if (-e[l]<delta) delta= e[k];
            int to = l[0];
            do {
                int from = prev.get(to);
                assert from != to;

                // residual
                int itccb = 0;
                while ((itccb < rCostCapBackward.get(from).size())
                        && (rCostCapBackward.get(from).get(itccb).getTo() != to)) {
                    itccb++;
                }
                if (itccb < rCostCapBackward.get(from).size()) {
                    if (rCostCapBackward.get(from).get(itccb).getResidualCapacity() < delta) {
                        delta = rCostCapBackward.get(from).get(itccb).getResidualCapacity();
                    }
                }

                to = from;
            } while (to != k);

            // augment delta flow from k to l (backwards actually...)
            to = l[0];
            do {
                int from = prev.get(to);
                assert from != to;

                // TODO - might do here O(n) can be done in O(1)
                int itx = 0;
                while (x.get(from).get(itx).getTo() != to) {
                    itx++;
                }
                tmp = x.get(from).get(itx).getFlow();
                x.get(from).get(itx).setFlow(tmp + delta);

                // update residual for backward edges
                int itccb = 0;
                while ((itccb < rCostCapBackward.get(to).size())
                        && (rCostCapBackward.get(to).get(itccb).getTo() != from)) {
                    itccb++;
                }
                if (itccb < rCostCapBackward.get(to).size()) {
                    tmp = rCostCapBackward.get(to).get(itccb).getResidualCapacity();
                    rCostCapBackward.get(to).get(itccb).setResidualCapacity(tmp + delta);
                }
                itccb = 0;
                while ((itccb < rCostCapBackward.get(from).size())
                        && (rCostCapBackward.get(from).get(itccb).getTo() != to)) {
                    itccb++;
                }
                if (itccb < rCostCapBackward.get(from).size()) {
                    tmp = rCostCapBackward.get(from).get(itccb).getResidualCapacity();
                    rCostCapBackward.get(from).get(itccb).setResidualCapacity(tmp - delta);
                }

                // update e
                e.set(to, e.get(to) + delta);
                e.set(from, e.get(from) - delta);

                to = from;
            } while (to != k);
        }

        // compute distance from x
        long dist = 0;
        for (int from = 0; from < numNodes; from++) {
            for (EdgeFlow it : x.get(from)) {
                dist += it.getCost() * it.getFlow();
            }
        }
        return dist;
    }
506760
protected void initialize(T input , GrayS32 output ) {
		this.graph = output;
		final int N = input.width*input.height;

		regionSize.resize(N);
		threshold.resize(N);
		for( int i = 0; i < N; i++ ) {
			regionSize.data[i] = 1;
			threshold.data[i] = K;
			graph.data[i] = i; // assign a unique label to each pixel since they are all their own region initially
		}

		edges.reset();
		edgesNotMatched.reset();
	}
1126983
@Override
	public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// u, v, w, bitmask
		DataSet<TriangleListing.Result<K>> triangles = input
			.run(new TriangleListing<K, VV, EV>()
				.setParallelism(parallelism));

		// u, edge count
		DataSet<Tuple2<K, LongValue>> triangleVertices = triangles
			.flatMap(new SplitTriangles<>())
				.name("Split triangle vertices");

		// u, triangle count
		DataSet<Tuple2<K, LongValue>> vertexTriangleCount = triangleVertices
			.groupBy(0)
			.reduce(new CountTriangles<>())
			.setCombineHint(CombineHint.HASH)
				.name("Count triangles")
				.setParallelism(parallelism);

		// u, deg(u)
		DataSet<Vertex<K, Degrees>> vertexDegree = input
			.run(new VertexDegrees<K, VV, EV>()
				.setIncludeZeroDegreeVertices(includeZeroDegreeVertices.get())
				.setParallelism(parallelism));

		// u, deg(u), triangle count
		return vertexDegree
			.leftOuterJoin(vertexTriangleCount)
			.where(0)
			.equalTo(0)
			.with(new JoinVertexDegreeWithTriangleCount<>())
				.setParallelism(parallelism)
				.name("Clustering coefficient");
	}
1038557
@Override
    public EdgeIteratorState edge(int nodeA, int nodeB) {
        if (isFrozen())
            throw new IllegalStateException("Cannot create edge if graph is already frozen");

        ensureNodeIndex(Math.max(nodeA, nodeB));
        int edgeId = edgeAccess.internalEdgeAdd(nextEdgeId(), nodeA, nodeB);
        EdgeIterable iter = new EdgeIterable(this, edgeAccess, EdgeFilter.ALL_EDGES);
        boolean ret = iter.init(edgeId, nodeB);
        assert ret;
        if (extStorage.isRequireEdgeField())
            iter.setAdditionalField(extStorage.getDefaultEdgeFieldValue());

        return iter;
    }
627880
@Override
	public Graph<K, VV, EV> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// u, d(u)
		DataSet<Vertex<K, LongValue>> vertexDegree = input
			.run(new VertexDegree<K, VV, EV>()
				.setReduceOnTargetId(reduceOnTargetId.get())
				.setParallelism(parallelism));

		// u, d(u) if d(u) > maximumDegree
		DataSet<Tuple1<K>> highDegreeVertices = vertexDegree
			.flatMap(new DegreeFilter<>(maximumDegree))
				.setParallelism(parallelism)
				.name("Filter high-degree vertices");

		JoinHint joinHint = broadcastHighDegreeVertices.get() ? JoinHint.BROADCAST_HASH_SECOND : JoinHint.REPARTITION_HASH_SECOND;

		// Vertices
		DataSet<Vertex<K, VV>> vertices = input
			.getVertices()
			.leftOuterJoin(highDegreeVertices, joinHint)
			.where(0)
			.equalTo(0)
			.with(new ProjectVertex<>())
				.setParallelism(parallelism)
				.name("Project low-degree vertices");

		// Edges
		DataSet<Edge<K, EV>> edges = input
			.getEdges()
			.leftOuterJoin(highDegreeVertices, joinHint)
			.where(reduceOnTargetId.get() ? 1 : 0)
			.equalTo(0)
				.with(new ProjectEdge<>())
				.setParallelism(parallelism)
				.name("Project low-degree edges by " + (reduceOnTargetId.get() ? "target" : "source"))
			.leftOuterJoin(highDegreeVertices, joinHint)
			.where(reduceOnTargetId.get() ? 0 : 1)
			.equalTo(0)
			.with(new ProjectEdge<>())
				.setParallelism(parallelism)
				.name("Project low-degree edges by " + (reduceOnTargetId.get() ? "source" : "target"));

		// Graph
		return Graph.fromDataSet(vertices, edges, input.getContext());
	}
350214
private void scan(CallGraphNode node) throws CFGBuilderException {
        Method method = node.getMethod();
        CFG cfg = classContext.getCFG(method);

        if (method.isSynchronized()) {
            hasSynchronization = true;
        }

        Iterator<BasicBlock> i = cfg.blockIterator();
        while (i.hasNext()) {
            BasicBlock block = i.next();
            Iterator<InstructionHandle> j = block.instructionIterator();
            while (j.hasNext()) {
                InstructionHandle handle = j.next();

                Instruction ins = handle.getInstruction();
                if (ins instanceof InvokeInstruction) {
                    InvokeInstruction inv = (InvokeInstruction) ins;
                    Method called = isSelfCall(inv);
                    if (called != null) {
                        // Add edge to call graph
                        CallSite callSite = new CallSite(method, block, handle);
                        callGraph.createEdge(node, callGraph.getNodeForMethod(called), callSite);

                        // Add to called method set
                        calledMethodSet.add(called);
                    }
                } else if (ins instanceof MONITORENTER || ins instanceof MONITOREXIT) {
                    hasSynchronization = true;
                }
            }
        }
    }
1062136
public static <K, VV, EV> Graph<K, VV, EV> fromDataSet(DataSet<Vertex<K, VV>> vertices,
			DataSet<Edge<K, EV>> edges, ExecutionEnvironment context) {

		return new Graph<>(vertices, edges, context);
	}
531755
private Graph initNewGraph(GDLParser.GraphContext graphContext) {
    Graph g = new Graph();
    g.setId(getNewGraphId());
    List<String> labels = getLabels(graphContext.header());
    g.setLabels(labels.isEmpty() ?
      useDefaultGraphLabel ? Collections.singletonList(defaultGraphLabel) : Collections.emptyList()
      : labels);
    g.setProperties(getProperties(graphContext.properties()));

    return g;
  }
733975
function loadPrettyGraphSON(graph, filename, callback) {
        // We need to create an input stream and a reader, both of which are created asyncrously in parallel.
        // It would be nice to use Bluebird.join() perform those two operations, but the declaration for join()
        // in bluebird.d.ts isn't correct. We instead use .all(), and furthermore we use these two local variables
        // to commuicate the results of the two async operations to the final join operation.
        var theStream;
        var theReader;
        function getStream() {
            var readFileP = BluePromise.promisify(fs.readFile);
            return readFileP(filename, 'utf8')
                .then(function (jsonText) {
                var jsonObjArray = JSON.parse(jsonText);
                var jsonTextArray = _.map(jsonObjArray, JSON.stringify);
                return jsonTextArray.join('\n');
            })
                .then(function (uglyText) {
                var StringInputStream = Tinkerpop.autoImport('StringInputStream');
                theStream = StringInputStream.from(uglyText);
                return theStream;
            });
        }
        function getGraphReader() {
            return Tinkerpop.GraphSONReader.buildP()
                .then(function (builder) {
                return _newGraphSONMapper()
                    .then(function (mapper) { return builder.mapperP(mapper); });
            })
                .then(function (builder) { return builder.createP(); })
                .then(function (reader) { theReader = reader; return theReader; });
        }
        return BluePromise.all([getStream(), getGraphReader()])
            .then(function () { return theReader.readGraphP(theStream, graph); })
            .then(function () { return graph; })
            .nodeify(callback);
    }
635313
@Override
	public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
			throws Exception {
		// s, d(s), 1/log(d(s))
		DataSet<Tuple3<K, LongValue, FloatValue>> inverseLogDegree = input
			.run(new VertexDegree<K, VV, EV>()
				.setParallelism(parallelism))
			.map(new VertexInverseLogDegree<>())
				.setParallelism(parallelism)
				.name("Vertex score");

		// s, t, 1/log(d(s))
		DataSet<Tuple3<K, K, FloatValue>> sourceInverseLogDegree = input
			.getEdges()
			.join(inverseLogDegree, JoinHint.REPARTITION_HASH_SECOND)
			.where(0)
			.equalTo(0)
			.projectFirst(0, 1)
			.<Tuple3<K, K, FloatValue>>projectSecond(2)
				.setParallelism(parallelism)
				.name("Edge score");

		// group span, s, t, 1/log(d(s))
		DataSet<Tuple4<IntValue, K, K, FloatValue>> groupSpans = sourceInverseLogDegree
			.groupBy(0)
			.sortGroup(1, Order.ASCENDING)
			.reduceGroup(new GenerateGroupSpans<>())
				.setParallelism(parallelism)
				.name("Generate group spans");

		// group, s, t, 1/log(d(s))
		DataSet<Tuple4<IntValue, K, K, FloatValue>> groups = groupSpans
			.rebalance()
				.setParallelism(parallelism)
				.name("Rebalance")
			.flatMap(new GenerateGroups<>())
				.setParallelism(parallelism)
				.name("Generate groups");

		// t, u, 1/log(d(s)) where (s, t) and (s, u) are edges in graph
		DataSet<Tuple3<K, K, FloatValue>> twoPaths = groups
			.groupBy(0, 1)
			.sortGroup(2, Order.ASCENDING)
			.reduceGroup(new GenerateGroupPairs<>())
				.name("Generate group pairs");

		// t, u, adamic-adar score
		GroupReduceOperator<Tuple3<K, K, FloatValue>, Result<K>> scores = twoPaths
			.groupBy(0, 1)
			.reduceGroup(new ComputeScores<>(minimumScore, minimumRatio))
				.name("Compute scores");

		if (minimumRatio > 0.0f) {
			// total score, number of pairs of neighbors
			DataSet<Tuple2<FloatValue, LongValue>> sumOfScoresAndNumberOfNeighborPairs = inverseLogDegree
				.map(new ComputeScoreFromVertex<>())
					.setParallelism(parallelism)
					.name("Average score")
				.sum(0)
				.andSum(1);

			scores
				.withBroadcastSet(sumOfScoresAndNumberOfNeighborPairs, SUM_OF_SCORES_AND_NUMBER_OF_NEIGHBOR_PAIRS);
		}

		if (mirrorResults) {
			return scores
				.flatMap(new MirrorResult<>())
					.name("Mirror results");
		} else {
			return scores;
		}
	}
567697
def process_input_graph(func):
    """"""
    @wraps(func)
    def wrapped_func(*args, **kwargs):
        input_graph = args[0]
        if isinstance(input_graph, nx.DiGraph):
            return func(*args, **kwargs)
        else:
            nx_graph = dict_to_nx(args[0], oriented=True)
            args = [nx_graph] + list(args[1:])
            return func(*args, **kwargs)
    return wrapped_func