本文整理了Java中org.apache.giraph.graph.Vertex.voteToHalt()
方法的一些代码示例,展示了Vertex.voteToHalt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.voteToHalt()
方法的具体详情如下:
包路径:org.apache.giraph.graph.Vertex
类名称:Vertex
方法名:voteToHalt
[英]After this is called, the compute() code will no longer be called for this vertex unless a message is sent to it. Then the compute() code will be called once again until this function is called. The application finishes only when all vertices vote to halt.
[中]调用该顶点后,将不再为此顶点调用compute()代码,除非向其发送消息。然后将再次调用compute()代码,直到调用此函数为止。只有当所有顶点投票停止时,应用程序才会结束。
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(Vertex<I, V, E> vertex,
Iterable<M> messages) throws IOException {
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<LongWritable, NullWritable, DoubleWritable> vertex,
Iterable<Writable> messages) throws IOException {
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<LongWritable, NullWritable, DoubleBooleanPair> vertex,
Iterable<Writable> messages) throws IOException {
vertex.voteToHalt();
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(
Vertex<LongWritable, DoubleWritable, FloatWritable> vertex,
Iterable<DoubleWritable> messages) throws IOException {
counter++;
if (getSuperstep() > 5) {
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<WritableComparable, Writable, Writable> vertex,
Iterable<WritableComparable> messages) throws IOException {
int count = 0;
for (WritableComparable msg : messages) {
// If this vertex has a neighbor with this ID, then this means it
// participates in a triangle.
if (vertex.getEdgeValue(msg)!=null) {
count++;
}
}
if (count>0) {
vertex.setValue(new IntWritable(count));
}
vertex.voteToHalt();
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
/**
* Send message wrapper for the Bracha Toueg algorithm specific for ACK
* messages.
*
* @param receiver recipient of the message
* @param vertex vertex sending the message
*/
private void sendAckMessage(long receiver, Vertex<LongWritable,
BrachaTouegDeadlockVertexValue, LongWritable> vertex) {
this.sendMessage(Long.valueOf(vertex.getId().get()),
receiver, BrachaTouegDeadlockMessage.ACK);
if (!vertex.getValue().isNotified()) {
vertex.voteToHalt();
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(Vertex<IntWritable, IntWritable, NullWritable> vertex,
Iterable<IntWritable> messages) throws IOException {
boolean changed = false;
for (IntWritable message : messages) {
if (vertex.getValue().get() < message.get()) {
vertex.setValue(message);
changed = true;
}
}
if (getSuperstep() == 0 || changed) {
sendMessageToAllEdges(vertex, vertex.getValue());
}
vertex.voteToHalt();
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(
Vertex<LongWritable, LongWritable, DoubleWritable> vertex,
Iterable<DoubleWritable> messages) throws IOException {
LongWritable vertexValue = vertex.getValue();
vertexValue.set(vertex.getNumEdges());
vertex.setValue(vertexValue);
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, NullWritable, DoubleWritable> vertex,
Iterable<LongIdFriendsList> messages) throws IOException {
for (Edge<LongWritable, DoubleWritable> e: vertex.getEdges()) {
vertex.setEdgeValue(e.getTargetVertexId(), covertToDistance(e.getValue()));
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, NullWritable, DoubleWritable> vertex,
Iterable<LongIdBloomFilter> messages) throws IOException {
for (Edge<LongWritable, DoubleWritable> e: vertex.getEdges()) {
vertex.setEdgeValue(e.getTargetVertexId(), covertToDistance(e.getValue()));
}
vertex.voteToHalt();
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(
Vertex<LongWritable, IntWritable, FloatWritable> vertex,
Iterable<DoubleWritable> messages) throws IOException {
long superstep = getSuperstep();
if (superstep < TESTLENGTH) {
EmitterWorkerContext emitter = getWorkerContext();
emitter.emit("vertexId=" + vertex.getId() +
" superstep=" + superstep + "\n");
} else {
vertex.voteToHalt();
}
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<CfLongId, FloatMatrixWritable, FloatWritable> vertex,
Iterable<FloatMatrixMessage> messages) throws IOException {
FloatMatrixWritable vector =
new FloatMatrixWritable(getContext().getConfiguration().getInt(
VECTOR_SIZE, VECTOR_SIZE_DEFAULT));
Random randGen = new Random();
for (int i=0; i<vector.length; i++) {
vector.put(i, 0.01f*randGen.nextFloat());
}
vertex.setValue(vector);
for (Edge<CfLongId, FloatWritable> edge : vertex.getEdges()) {
FloatMatrixMessage msg = new FloatMatrixMessage(
vertex.getId(), vertex.getValue(), edge.getValue().get());
sendMessage(edge.getTargetVertexId(), msg);
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, DoubleWritable, DoubleWritable> vertex,
Iterable<LongIdAndValueBloomFilter> messages) throws IOException {
for (Edge<LongWritable, DoubleWritable> e: vertex.getEdges()) {
vertex.setEdgeValue(e.getTargetVertexId(),
new DoubleWritable(e.getValue().get()*(-1.0)));
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, DoubleWritable, DoubleWritable> vertex,
Iterable<LongIdDoubleValueFriendsList> messages) throws IOException {
for (Edge<LongWritable, DoubleWritable> e: vertex.getEdges()) {
vertex.setEdgeValue(e.getTargetVertexId(),
new DoubleWritable(e.getValue().get()*(-1.0)));
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<CfLongId, FloatMatrixWritable, BooleanWritable> vertex,
Iterable<FloatMatrixMessage> messages) throws IOException {
minItemId = Integer.parseInt(getConf().get("minItemId"));
maxItemId = Integer.parseInt(getConf().get("maxItemId"));
numberSamples = Integer.parseInt(getConf().get("numberSamples", "100"));
k = Integer.parseInt(getConf().get("k", "5"));
if (getSuperstep() == 0){
sampleIrrelevantEdges(vertex);
sendUserDataToItems(vertex);
}else if(getSuperstep() == 1){
computeScoreAndSendBack(vertex, messages);
}else if(getSuperstep() == 2){
computeRankingMeasure(vertex, messages);
}
vertex.voteToHalt();
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<WritableComparable, Writable, Writable> vertex,
Iterable<Writable> messages) throws IOException {
for (Edge<WritableComparable, Writable> edge: vertex.getEdges()) {
if (edge.getTargetVertexId().compareTo(vertex.getId()) > 0) {
sendMessage(edge.getTargetVertexId(), vertex.getId());
}
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<LongWritable, NullWritable,DoubleWritable> vertex,
Iterable<Writable> messages) throws IOException {
for (Edge<LongWritable, DoubleWritable> edge: vertex.getEdges()) {
if (edge.getTargetVertexId().compareTo(vertex.getId()) > 0) {
sendMessage(edge.getTargetVertexId(), vertex.getId());
}
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<WritableComparable, Writable, Writable> vertex,
Iterable<WritableComparable> messages) throws IOException {
for (WritableComparable msg : messages) {
assert(msg.compareTo(vertex.getId())<0); // This can never happen
for (Edge<WritableComparable, Writable> edge: vertex.getEdges()) {
if (vertex.getId().compareTo(edge.getTargetVertexId()) < 0) {
sendMessage(edge.getTargetVertexId(), msg);
}
}
}
vertex.voteToHalt();
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(Vertex<CfLongId, FloatMatrixWritable, FloatWritable> vertex, Iterable<FloatMatrixMessage> messages) throws IOException {
vertex.setValue(new FloatMatrixWritable(FloatMatrix.rand(DIM)));
if(getSuperstep() == 0){
Iterable<Edge<CfLongId, FloatWritable>> edges = vertex.getEdges();
sendMessage(vertex.getId(), emptyMsg); //send message to myself in order to be executed in the next super step
for (Edge<CfLongId, FloatWritable> edge : edges) {
sendMessage(edge.getTargetVertexId(), new FloatMatrixMessage(vertex.getId(), emptyList, edge.getValue().get()));
}
}
vertex.voteToHalt();
}
代码示例来源:origin: org.apache.giraph/giraph-core
@Override
public void compute(
Vertex<IntWritable, FloatWritable, NullWritable> vertex,
Iterable<FloatWritable> messages) throws IOException {
if (getSuperstep() >= 1) {
float sum = 0;
for (FloatWritable message : messages) {
sum += message.get();
}
vertex.getValue().set((0.15f / getTotalNumVertices()) + 0.85f * sum);
}
if (getSuperstep() < getConf().getInt(SUPERSTEP_COUNT, 0)) {
sendMessageToAllEdges(vertex,
new FloatWritable(vertex.getValue().get() / vertex.getNumEdges()));
} else {
vertex.voteToHalt();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!