@Override public GraphAnalytic<K, VV, EV, T> run(Graph<K, VV, EV> input) throws Exception { env = input.getContext(); return this; }
@Override public Graph<K, VV, NEW> runInternal(Graph<K, VV, OLD> input) throws Exception { DataSet<Edge<K, NEW>> translatedEdges = translateEdgeValues(input.getEdges(), translator, parallelism); return Graph.fromDataSet(input.getVertices(), translatedEdges, input.getContext()); } }
@Override public Graph<K, NEW, EV> runInternal(Graph<K, OLD, EV> input) throws Exception { DataSet<Vertex<K, NEW>> translatedVertices = translateVertexValues(input.getVertices(), translator, parallelism); return Graph.fromDataSet(translatedVertices, input.getEdges(), input.getContext()); } }
@Override public Graph<NEW, VV, EV> runInternal(Graph<OLD, VV, EV> input) throws Exception { // Vertices DataSet<Vertex<NEW, VV>> translatedVertices = translateVertexIds(input.getVertices(), translator, parallelism); // Edges DataSet<Edge<NEW, EV>> translatedEdges = translateEdgeIds(input.getEdges(), translator, parallelism); // Graph return Graph.fromDataSet(translatedVertices, translatedEdges, input.getContext()); } }
edgesWrappingOperator = other.edgesWrappingOperator; return Graph.fromDataSet(verticesWrappingOperator, edgesWrappingOperator, output.getContext()); return Graph.fromDataSet(verticesWrappingOperator, edgesWrappingOperator, output.getContext());
/** * Performs intersect on the edge sets of the input graphs. Edges are considered equal, if they * have the same source identifier, target identifier and edge value. * * <p>The method computes pairs of equal edges from the input graphs. If the same edge occurs * multiple times in the input graphs, there will be multiple edge pairs to be considered. Each * edge instance can only be part of one pair. If the given parameter {@code distinctEdges} is set * to {@code true}, there will be exactly one edge in the output graph representing all pairs of * equal edges. If the parameter is set to {@code false}, both edges of each pair will be in the * output. * * <p>Vertices in the output graph will have no vertex values. * * @param graph the graph to perform intersect with * @param distinctEdges if set to {@code true}, there will be exactly one edge in the output graph * representing all pairs of equal edges, otherwise, for each pair, both * edges will be in the output graph * @return a new graph which contains only common vertices and edges from the input graphs */ public Graph<K, NullValue, EV> intersect(Graph<K, VV, EV> graph, boolean distinctEdges) { DataSet<Edge<K, EV>> intersectEdges; if (distinctEdges) { intersectEdges = getDistinctEdgeIntersection(graph.getEdges()); } else { intersectEdges = getPairwiseEdgeIntersection(graph.getEdges()); } return Graph.fromDataSet(intersectEdges, getContext()); }
@Override public Graph<K, Long, Double> run(Graph<K, Long, Double> graph) { DataSet<Vertex<K, Tuple2<Long, Double>>> initializedVertices = graph.getVertices() .map(new AddScoreToVertexValuesMapper<>()); Graph<K, Tuple2<Long, Double>, Double> graphWithScoredVertices = Graph.fromDataSet(initializedVertices, graph.getEdges(), graph.getContext()).getUndirected(); return graphWithScoredVertices.runScatterGatherIteration(new LabelMessenger<>(), new VertexLabelUpdater<>(delta), maxIterations) .mapVertices(new RemoveScoreFromVertexValuesMapper<>()); }
@Override public Graph<K, VV, EV> runInternal(Graph<K, VV, EV> input) throws Exception { // Edges DataSet<Edge<K, EV>> edges = input .getEdges() .filter(new RemoveSelfLoops<>()) .setParallelism(parallelism) .name("Remove self-loops") .distinct(0, 1) .setCombineHint(CombineHint.NONE) .setParallelism(parallelism) .name("Remove duplicate edges"); // Graph return Graph.fromDataSet(input.getVertices(), edges, input.getContext()); }
@Override public Graph<K, VV, EV> runInternal(Graph<K, VV, EV> input) throws Exception { // Edges DataSet<Edge<K, EV>> edges = input .getEdges() .flatMap(new SymmetrizeAndRemoveSelfLoops<>(clipAndFlip)) .setParallelism(parallelism) .name("Remove self-loops") .distinct(0, 1) .setCombineHint(CombineHint.NONE) .setParallelism(parallelism) .name("Remove duplicate edges"); // Graph return Graph.fromDataSet(input.getVertices(), edges, input.getContext()); }
.reduceGroup(new EdgeGroupReducer<>()); return Graph.fromDataSet(summarizedVertices, summarizedEdges, input.getContext());
return Graph.fromDataSet(vertices, edges, input.getContext());
@Override public GraphAnalytic<K, VV, EV, T> run(Graph<K, VV, EV> input) throws Exception { env = input.getContext(); return this; }
@Override public GraphAnalytic<K, VV, EV, T> run(Graph<K, VV, EV> input) throws Exception { env = input.getContext(); return this; }
@Override public GraphAnalytic<K, VV, EV, T> run(Graph<K, VV, EV> input) throws Exception { env = input.getContext(); return this; }
@Override public Graph<K, NEW, EV> runInternal(Graph<K, OLD, EV> input) throws Exception { DataSet<Vertex<K, NEW>> translatedVertices = translateVertexValues(input.getVertices(), translator, parallelism); return Graph.fromDataSet(translatedVertices, input.getEdges(), input.getContext()); } }
@Override public Graph<K, NEW, EV> runInternal(Graph<K, OLD, EV> input) throws Exception { DataSet<Vertex<K, NEW>> translatedVertices = translateVertexValues(input.getVertices(), translator, parallelism); return Graph.fromDataSet(translatedVertices, input.getEdges(), input.getContext()); } }
@Override public Graph<K, VV, NEW> runInternal(Graph<K, VV, OLD> input) throws Exception { DataSet<Edge<K, NEW>> translatedEdges = translateEdgeValues(input.getEdges(), translator, parallelism); return Graph.fromDataSet(input.getVertices(), translatedEdges, input.getContext()); } }
@Override public Graph<NEW, VV, EV> runInternal(Graph<OLD, VV, EV> input) throws Exception { // Vertices DataSet<Vertex<NEW, VV>> translatedVertices = translateVertexIds(input.getVertices(), translator, parallelism); // Edges DataSet<Edge<NEW, EV>> translatedEdges = translateEdgeIds(input.getEdges(), translator, parallelism); // Graph return Graph.fromDataSet(translatedVertices, translatedEdges, input.getContext()); } }
@Override public Graph<K, Long, Double> run(Graph<K, Long, Double> graph) { DataSet<Vertex<K, Tuple2<Long, Double>>> initializedVertices = graph.getVertices() .map(new AddScoreToVertexValuesMapper<K>()); Graph<K, Tuple2<Long, Double>, Double> graphWithScoredVertices = Graph.fromDataSet(initializedVertices, graph.getEdges(), graph.getContext()).getUndirected(); return graphWithScoredVertices.runScatterGatherIteration(new LabelMessenger<K>(), new VertexLabelUpdater<K>(delta), maxIterations) .mapVertices(new RemoveScoreFromVertexValuesMapper<K>()); }
@Override public Graph<K, Long, Double> run(Graph<K, Long, Double> graph) { DataSet<Vertex<K, Tuple2<Long, Double>>> initializedVertices = graph.getVertices() .map(new AddScoreToVertexValuesMapper<>()); Graph<K, Tuple2<Long, Double>, Double> graphWithScoredVertices = Graph.fromDataSet(initializedVertices, graph.getEdges(), graph.getContext()).getUndirected(); return graphWithScoredVertices.runScatterGatherIteration(new LabelMessenger<>(), new VertexLabelUpdater<>(delta), maxIterations) .mapVertices(new RemoveScoreFromVertexValuesMapper<>()); }