/** * Creates a new scatter-gather iteration operator for graphs where the edges are associated with a value (such as * a weight or distance). * * @param edgesWithValue The data set containing edges. * @param sf The function that turns changed vertex states into messages along the edges. * @param gf The function that updates the state of the vertices from the incoming messages. * * @param <K> The type of the vertex key (the vertex identifier). * @param <VV> The type of the vertex value (the state of the vertex). * @param <Message> The type of the message sent between vertices along the edges. * @param <EV> The type of the values that are associated with the edges. * * @return An in stance of the scatter-gather graph computation operator. */ public static <K, VV, Message, EV> ScatterGatherIteration<K, VV, Message, EV> withEdges( DataSet<Edge<K, EV>> edgesWithValue, ScatterFunction<K, VV, Message, EV> sf, GatherFunction<K, VV, Message> gf, int maximumNumberOfIterations) { return new ScatterGatherIteration<>(sf, gf, edgesWithValue, maximumNumberOfIterations); }
setUpIteration(iteration); messages = buildScatterFunction(iteration, messageTypeInfo, 1, 0, numberOfVertices); break; case OUT: messages = buildScatterFunction(iteration, messageTypeInfo, 0, 0, numberOfVertices); break; case ALL: messages = buildScatterFunction(iteration, messageTypeInfo, 1, 0, numberOfVertices) .union(buildScatterFunction(iteration, messageTypeInfo, 0, 0, numberOfVertices)); break; default: configureUpdateFunction(updates);
setUpIteration(iteration); messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices); break; case OUT: messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices); break; case ALL: messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices) .union(buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices)); break; default: configureUpdateFunction(updates);
/** * Runs a ScatterGather iteration on the graph with configuration options. * * @param scatterFunction the scatter function * @param gatherFunction the gather function * @param maximumNumberOfIterations maximum number of iterations to perform * @param parameters the iteration configuration parameters * * @return the updated Graph after the scatter-gather iteration has converged or * after maximumNumberOfIterations. */ public <M> Graph<K, VV, EV> runScatterGatherIteration( ScatterFunction<K, VV, M, EV> scatterFunction, org.apache.flink.graph.spargel.GatherFunction<K, VV, M> gatherFunction, int maximumNumberOfIterations, ScatterGatherConfiguration parameters) { ScatterGatherIteration<K, VV, M, EV> iteration = ScatterGatherIteration.withEdges( edges, scatterFunction, gatherFunction, maximumNumberOfIterations); iteration.configure(parameters); DataSet<Vertex<K, VV>> newVertices = this.getVertices().runOperation(iteration); return new Graph<>(newVertices, this.edges, this.context); }
return createResultVerticesWithDegrees(graph, messagingDirection, messageTypeInfo, numberOfVertices); } else { return createResultSimpleVertex(messagingDirection, messageTypeInfo, numberOfVertices);
private ScatterGatherIteration(ScatterFunction<K, VV, Message, EV> sf, GatherFunction<K, VV, Message> gf, DataSet<Edge<K, EV>> edgesWithValue, int maximumNumberOfIterations) { Preconditions.checkNotNull(sf); Preconditions.checkNotNull(gf); Preconditions.checkNotNull(edgesWithValue); Preconditions.checkArgument(maximumNumberOfIterations > 0, "The maximum number of iterations must be at least one."); this.scatterFunction = sf; this.gatherFunction = gf; this.edgesWithValue = edgesWithValue; this.maximumNumberOfIterations = maximumNumberOfIterations; this.messageType = getMessageType(sf); }
/** * Runs a ScatterGather iteration on the graph with configuration options. * * @param scatterFunction the scatter function * @param gatherFunction the gather function * @param maximumNumberOfIterations maximum number of iterations to perform * @param parameters the iteration configuration parameters * * @return the updated Graph after the scatter-gather iteration has converged or * after maximumNumberOfIterations. */ public <M> Graph<K, VV, EV> runScatterGatherIteration( ScatterFunction<K, VV, M, EV> scatterFunction, org.apache.flink.graph.spargel.GatherFunction<K, VV, M> gatherFunction, int maximumNumberOfIterations, ScatterGatherConfiguration parameters) { ScatterGatherIteration<K, VV, M, EV> iteration = ScatterGatherIteration.withEdges( edges, scatterFunction, gatherFunction, maximumNumberOfIterations); iteration.configure(parameters); DataSet<Vertex<K, VV>> newVertices = this.getVertices().runOperation(iteration); return new Graph<>(newVertices, this.edges, this.context); }
return createResultVerticesWithDegrees(graph, messagingDirection, messageTypeInfo, numberOfVertices); } else { return createResultSimpleVertex(messagingDirection, messageTypeInfo, numberOfVertices);
private ScatterGatherIteration(ScatterFunction<K, VV, Message, EV> sf, GatherFunction<K, VV, Message> gf, DataSet<Edge<K, EV>> edgesWithValue, int maximumNumberOfIterations) { Preconditions.checkNotNull(sf); Preconditions.checkNotNull(gf); Preconditions.checkNotNull(edgesWithValue); Preconditions.checkArgument(maximumNumberOfIterations > 0, "The maximum number of iterations must be at least one."); this.scatterFunction = sf; this.gatherFunction = gf; this.edgesWithValue = edgesWithValue; this.maximumNumberOfIterations = maximumNumberOfIterations; this.messageType = getMessageType(sf); }
setUpIteration(iteration); messages = buildScatterFunction(iteration, messageTypeInfo, 1, 0, numberOfVertices); break; case OUT: messages = buildScatterFunction(iteration, messageTypeInfo, 0, 0, numberOfVertices); break; case ALL: messages = buildScatterFunction(iteration, messageTypeInfo, 1, 0, numberOfVertices) .union(buildScatterFunction(iteration, messageTypeInfo, 0, 0, numberOfVertices)) ; break; default: configureUpdateFunction(updates);
setUpIteration(iteration); messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices); break; case OUT: messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices); break; case ALL: messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices) .union(buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices)) ; break; default: configureUpdateFunction(updates);
/** * Runs a ScatterGather iteration on the graph with configuration options. * * @param scatterFunction the scatter function * @param gatherFunction the gather function * @param maximumNumberOfIterations maximum number of iterations to perform * @param parameters the iteration configuration parameters * * @return the updated Graph after the scatter-gather iteration has converged or * after maximumNumberOfIterations. */ public <M> Graph<K, VV, EV> runScatterGatherIteration( ScatterFunction<K, VV, M, EV> scatterFunction, org.apache.flink.graph.spargel.GatherFunction<K, VV, M> gatherFunction, int maximumNumberOfIterations, ScatterGatherConfiguration parameters) { ScatterGatherIteration<K, VV, M, EV> iteration = ScatterGatherIteration.withEdges( edges, scatterFunction, gatherFunction, maximumNumberOfIterations); iteration.configure(parameters); DataSet<Vertex<K, VV>> newVertices = this.getVertices().runOperation(iteration); return new Graph<>(newVertices, this.edges, this.context); }
return createResultVerticesWithDegrees(graph, messagingDirection, messageTypeInfo, numberOfVertices); } else { return createResultSimpleVertex(messagingDirection, messageTypeInfo, numberOfVertices);
private ScatterGatherIteration(ScatterFunction<K, VV, Message, EV> sf, GatherFunction<K, VV, Message> gf, DataSet<Edge<K, EV>> edgesWithValue, int maximumNumberOfIterations) { Preconditions.checkNotNull(sf); Preconditions.checkNotNull(gf); Preconditions.checkNotNull(edgesWithValue); Preconditions.checkArgument(maximumNumberOfIterations > 0, "The maximum number of iterations must be at least one."); this.scatterFunction = sf; this.gatherFunction = gf; this.edgesWithValue = edgesWithValue; this.maximumNumberOfIterations = maximumNumberOfIterations; this.messageType = getMessageType(sf); }
/** * Creates a new scatter-gather iteration operator for graphs where the edges are associated with a value (such as * a weight or distance). * * @param edgesWithValue The data set containing edges. * @param sf The function that turns changed vertex states into messages along the edges. * @param gf The function that updates the state of the vertices from the incoming messages. * * @param <K> The type of the vertex key (the vertex identifier). * @param <VV> The type of the vertex value (the state of the vertex). * @param <Message> The type of the message sent between vertices along the edges. * @param <EV> The type of the values that are associated with the edges. * * @return An in stance of the scatter-gather graph computation operator. */ public static <K, VV, Message, EV> ScatterGatherIteration<K, VV, Message, EV> withEdges( DataSet<Edge<K, EV>> edgesWithValue, ScatterFunction<K, VV, Message, EV> sf, GatherFunction<K, VV, Message> gf, int maximumNumberOfIterations) { return new ScatterGatherIteration<>(sf, gf, edgesWithValue, maximumNumberOfIterations); }
setUpIteration(iteration); messages = buildScatterFunction(iteration, messageTypeInfo, 1, 0, numberOfVertices); break; case OUT: messages = buildScatterFunction(iteration, messageTypeInfo, 0, 0, numberOfVertices); break; case ALL: messages = buildScatterFunction(iteration, messageTypeInfo, 1, 0, numberOfVertices) .union(buildScatterFunction(iteration, messageTypeInfo, 0, 0, numberOfVertices)); break; default: configureUpdateFunction(updates);
setUpIteration(iteration); messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices); break; case OUT: messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices); break; case ALL: messages = buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 1, 0, numberOfVertices) .union(buildScatterFunctionVerticesWithDegrees(iteration, messageTypeInfo, 0, 0, numberOfVertices)); break; default: configureUpdateFunction(updates);
/** * Runs a ScatterGather iteration on the graph with configuration options. * * @param scatterFunction the scatter function * @param gatherFunction the gather function * @param maximumNumberOfIterations maximum number of iterations to perform * @param parameters the iteration configuration parameters * * @return the updated Graph after the scatter-gather iteration has converged or * after maximumNumberOfIterations. */ public <M> Graph<K, VV, EV> runScatterGatherIteration( ScatterFunction<K, VV, M, EV> scatterFunction, org.apache.flink.graph.spargel.GatherFunction<K, VV, M> gatherFunction, int maximumNumberOfIterations, ScatterGatherConfiguration parameters) { ScatterGatherIteration<K, VV, M, EV> iteration = ScatterGatherIteration.withEdges( edges, scatterFunction, gatherFunction, maximumNumberOfIterations); iteration.configure(parameters); DataSet<Vertex<K, VV>> newVertices = this.getVertices().runOperation(iteration); return new Graph<>(newVertices, this.edges, this.context); }
return createResultVerticesWithDegrees(graph, messagingDirection, messageTypeInfo, numberOfVertices); } else { return createResultSimpleVertex(messagingDirection, messageTypeInfo, numberOfVertices);
private ScatterGatherIteration(ScatterFunction<K, VV, Message, EV> sf, GatherFunction<K, VV, Message> gf, DataSet<Edge<K, EV>> edgesWithValue, int maximumNumberOfIterations) { Preconditions.checkNotNull(sf); Preconditions.checkNotNull(gf); Preconditions.checkNotNull(edgesWithValue); Preconditions.checkArgument(maximumNumberOfIterations > 0, "The maximum number of iterations must be at least one."); this.scatterFunction = sf; this.gatherFunction = gf; this.edgesWithValue = edgesWithValue; this.maximumNumberOfIterations = maximumNumberOfIterations; this.messageType = getMessageType(sf); }