本文整理了Java中org.apache.giraph.graph.Vertex.getValue()
方法的一些代码示例,展示了Vertex.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getValue()
方法的具体详情如下:
包路径:org.apache.giraph.graph.Vertex
类名称:Vertex
方法名:getValue
[英]Get the vertex value (data stored with vertex)
[中]获取顶点值(与顶点一起存储的数据)
代码示例来源:origin: apache/giraph
@Override
public V get(Vertex<I, V, E> vertex) {
return vertex.getValue();
}
};
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void writeVertex(
Vertex<LongWritable, DoubleWritable, DoubleWritable> vertex)
throws IOException, InterruptedException {
StringBuilder output = new StringBuilder();
output.append(vertex.getId().get());
output.append('\t');
output.append(vertex.getValue().get());
getRecordWriter().write(new Text(output.toString()), null);
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void writeVertex(
Vertex<LongWritable, DoubleWritable, NullWritable> vertex)
throws IOException, InterruptedException {
StringBuilder output = new StringBuilder();
output.append(vertex.getId().get());
output.append('\t');
output.append(vertex.getValue().get());
getRecordWriter().write(new Text(output.toString()), null);
}
}
代码示例来源:origin: grafos-ml/okapi
private void requestMigration(
Vertex<LongWritable, VertexValue, EdgeValue> vertex,
int numberOfEdges, short currentPartition, short newPartition) {
vertex.getValue().setNewPartition(newPartition);
aggregate(demandAggregatorNames[newPartition], new LongWritable(
numberOfEdges));
loads[newPartition] += numberOfEdges;
loads[currentPartition] -= numberOfEdges;
}
代码示例来源:origin: grafos-ml/okapi
@Override
protected Text convertVertexToLine(
Vertex<LongWritable, KMeansVertexValue, NullWritable> vertex)
throws IOException {
StringBuffer sb = new StringBuffer(vertex.getId().toString());
sb.append(delimiter);
sb.append(vertex.getValue().getClusterId().toString());
return new Text(sb.toString());
}
代码示例来源:origin: apache/giraph
/**
* Get Vertex Value for a given id.
*/
public V getValue(Number vertexId) {
return testGraph.getVertex(numberToVertexId(vertexId)).getValue();
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, VertexValue, DoubleWritable> vertex,
Iterable<DoubleWritable> messages) throws IOException {
if (vertex.getValue().isTrusted()) {
aggregate(AGGREGATOR_NUM_TRUSTED, ONE);
}
}
}
代码示例来源:origin: grafos-ml/okapi
/**
* We override this function as we need a special treatment for item biases. See the class documentation for the explanation.
*/
protected void initFactorsIfNeeded(Vertex<CfLongId,FloatMatrixWritable,FloatWritable> vertex) {
if (null == vertex.getValue() || vertex.getValue().columns != d+1){
vertex.setValue(new FloatMatrixWritable(FloatMatrix.rand(d + 1)));
}
if (vertex.getId().isUser()){//In BPR the first factor of the user is always 1, its to have item baselines
vertex.getValue().put(0, 1f);
}
}
代码示例来源:origin: org.apache.giraph/giraph-core
/**
* The backing store of the current vertex id is now released.
* Further calls to getCurrentVertexId () without calling next()
* will return null.
*
* @return Current vertex id that was released
*/
public I releaseCurrentVertexId() {
I releasedVertexId = vertex.getId();
vertex.initialize(null, vertex.getValue());
return releasedVertexId;
}
代码示例来源:origin: grafos-ml/okapi
@Override
protected Text convertVertexToLine(
Vertex<CfLongId, FloatMatrixWritable, BooleanWritable> vertex)
throws IOException {
if (outputEdge.equals(vertex.getId())){
return new Text(vertex.getValue().toString());
}
return null;
}
};
代码示例来源:origin: apache/giraph
@Override
public void apply(Vertex<LongWritable, LongWritable, Writable> vertex,
Iterable<LongWritable> messages) {
long max = 0;
for (LongWritable v : messages) {
max = Math.max(max, v.get());
}
vertex.getValue().set(max);
}
});
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void writeVertex(
Vertex<LongWritable, IntWritable, FloatWritable> vertex)
throws IOException, InterruptedException {
getRecordWriter().write(
new Text(vertex.getId().toString()),
new Text(vertex.getValue().toString()));
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void writeVertex(
Vertex<LongWritable, DoubleWritable, FloatWritable> vertex)
throws IOException, InterruptedException {
getRecordWriter().write(
new Text(vertex.getId().toString()),
new Text(vertex.getValue().toString()));
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void writeVertex(Vertex<LongWritable, IntWritable,
FloatWritable> vertex) throws IOException, InterruptedException {
getRecordWriter().write(
new Text(vertex.getId().toString()),
new Text(vertex.getValue().toString()));
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
/**
* Traverse the transposed graph and keep the maximum vertex value.
* @param vertex Current vertex.
*/
private void backwardTraversalStart(
Vertex<LongWritable, SccVertexValue, NullWritable> vertex) {
SccVertexValue vertexValue = vertex.getValue();
if (vertexValue.get() == vertex.getId().get()) {
messageValue.set(vertexValue.get());
sendMessageToAllParents(vertex, messageValue);
}
}
代码示例来源: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, KMeansVertexValue, NullWritable> vertex,
Iterable<NullWritable> messages) throws IOException {
ArrayListOfDoubleArrayListWritable value = new ArrayListOfDoubleArrayListWritable();
value.add(vertex.getValue().getPointCoordinates());
aggregate(INITIAL_CENTERS, value);
}
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(
Vertex<LongWritable, DoubleWritable, FloatWritable> vertex,
Iterable<DoubleWritable> messages) throws IOException {
double oldSum = getSuperstep() == 0 ? 0 : vertex.getValue().get();
double newValue = this.<DoubleWritable>getAggregatedValue(SMC_AGG).get();
double newSum = oldSum + newValue;
vertex.setValue(new DoubleWritable(newSum));
SimpleMasterComputeWorkerContext workerContext = getWorkerContext();
workerContext.setFinalSum(newSum);
LOG.info("Current sum: " + newSum);
}
代码示例来源:origin: org.apache.giraph/giraph-examples
@Override
public void compute(
Vertex<LongWritable, DoubleWritable, FloatWritable> vertex,
Iterable<DoubleWritable> messages) throws IOException {
double oldSum = getSuperstep() == 0 ? 0 : vertex.getValue().get();
double newValue = this.<DoubleWritable>getAggregatedValue(SMC_AGG).get();
double newSum = oldSum + newValue;
vertex.setValue(new DoubleWritable(newSum));
SimpleMigrationMasterWorkerContext workerContext = getWorkerContext();
workerContext.setFinalSum(newSum);
LOG.info("Current sum: " + newSum);
}
}
代码示例来源:origin: grafos-ml/okapi
public void computeScoreAndSendBack(
Vertex<CfLongId, FloatMatrixWritable, BooleanWritable> vertex,
Iterable<FloatMatrixMessage> messages) {
if (vertex.getId().isItem()){//only items send messages
for(FloatMatrixMessage msg : messages){
float score = msg.getFactors().dot(vertex.getValue());
FloatMatrixMessage msgToSendBack =
new FloatMatrixMessage(vertex.getId(), emptyList, score);
sendMessage(msg.getSenderId(), msgToSendBack);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!