本文整理了Java中org.apache.giraph.graph.Vertex.getId()
方法的一些代码示例,展示了Vertex.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vertex.getId()
方法的具体详情如下:
包路径:org.apache.giraph.graph.Vertex
类名称:Vertex
方法名:getId
[英]Get the vertex id.
[中]获取顶点id。
代码示例来源:origin: apache/giraph
@Override
public I get(Vertex<I, V, E> vertex) {
return vertex.getId();
}
};
代码示例来源:origin: org.apache.giraph/giraph-core
/**
* Set vertex, replace if there was already a vertex with same id added
*
* @param vertex Vertex
* @return this
*/
public TestGraph<I, V, E> setVertex(Vertex<I, V, E> vertex) {
vertices.put(vertex.getId(), vertex);
return this;
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void setClass() {
setClass(_vertex.getId().getClass());
}
};
代码示例来源:origin: grafos-ml/okapi
@Override
public void setClass() {
setClass(_vertex.getId().getClass());
}
};
代码示例来源:origin: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, VertexValue, EdgeValue> vertex,
Iterable<LongWritable> messages) throws IOException {
sendMessageToAllEdges(vertex, vertex.getId());
}
}
代码示例来源:origin: grafos-ml/okapi
@Override
public void setClass() {
setClass(_vertex.getId().getClass());
}
};
代码示例来源:origin: grafos-ml/okapi
/**
* Is this vertex the source id?
*
* @return True if the source id
*/
private boolean isSource(
Vertex<LongWritable, DoubleWritable, FloatWritable> vertex) {
return vertex.getId().get() ==
getContext().getConfiguration().getLong(SOURCE_ID,
SOURCE_ID_DEFAULT);
}
代码示例来源: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: org.apache.giraph/giraph-core
/**
* Check if vertex is source from which to calculate shortest paths.
*
* @param vertex Vertex
* @return True iff vertex is source for shortest paths
*/
private boolean isSource(
Vertex<LongWritable, DoubleWritable, DoubleWritable> vertex) {
return vertex.getId().get() ==
getConf().getLong(SOURCE_ID, SOURCE_ID_DEFAULT);
}
代码示例来源: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: 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: org.apache.giraph/giraph-core
@Override
public void writeVertex(
Vertex<WritableComparable, Writable, Writable> vertex)
throws IOException, InterruptedException {
StringBuilder sb = new StringBuilder(vertex.getNumEdges() * 10);
for (Edge<WritableComparable, Writable> edge : vertex.getEdges()) {
addEdge(sb, vertex.getId(), edge);
}
addNodeInfo(vertex, sb);
getRecordWriter().write(new Text(sb.toString()), null);
}
}
代码示例来源: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: 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, IntWritable,
FloatWritable> vertex) throws IOException, InterruptedException {
getRecordWriter().write(
new Text(vertex.getId().toString()),
new Text(vertex.getValue().toString()));
}
}
代码示例来源: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);
}
}
}
代码示例来源: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: grafos-ml/okapi
@Override
public void compute(
Vertex<LongWritable, NullWritable, DoubleWritable> vertex,
Iterable<LongIdBloomFilter> messages) throws IOException {
BloomFilter filter = new BloomFilter(numBits, numFunctions, hashType);
for (Edge<LongWritable, DoubleWritable> e : vertex.getEdges()) {
filter.add(new Key(Longs.toByteArray(e.getTargetVertexId().get())));
}
sendMessageToAllEdges(vertex,
new LongIdBloomFilter(vertex.getId(), filter, vertex.getNumEdges()));
}
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!