use of com.baidu.hugegraph.structure.graph.Vertex in project hugegraph-computer by hugegraph.
the class BetweennessCentralityTest method setup.
@BeforeClass
public static void setup() {
clearAll();
HugeClient client = client();
SchemaManager schema = client.schema();
schema.vertexLabel("user").useCustomizeStringId().ifNotExist().create();
schema.edgeLabel("link").sourceLabel("user").targetLabel("user").ifNotExist().create();
GraphManager graph = client.graph();
Vertex v0 = graph.addVertex(T.label, "user", T.id, "0");
Vertex v1 = graph.addVertex(T.label, "user", T.id, "1");
Vertex v2 = graph.addVertex(T.label, "user", T.id, "2");
Vertex v3 = graph.addVertex(T.label, "user", T.id, "3");
Vertex v4 = graph.addVertex(T.label, "user", T.id, "4");
Vertex v5 = graph.addVertex(T.label, "user", T.id, "5");
Vertex v6 = graph.addVertex(T.label, "user", T.id, "6");
Vertex v7 = graph.addVertex(T.label, "user", T.id, "7");
v0.addEdge("link", v1);
v0.addEdge("link", v2);
v1.addEdge("link", v0);
v1.addEdge("link", v2);
v1.addEdge("link", v5);
v2.addEdge("link", v0);
v2.addEdge("link", v1);
v2.addEdge("link", v3);
v2.addEdge("link", v4);
v3.addEdge("link", v2);
v3.addEdge("link", v4);
v3.addEdge("link", v5);
v4.addEdge("link", v2);
v4.addEdge("link", v3);
v4.addEdge("link", v5);
v4.addEdge("link", v6);
v4.addEdge("link", v7);
v5.addEdge("link", v1);
v5.addEdge("link", v3);
v5.addEdge("link", v4);
v5.addEdge("link", v6);
v5.addEdge("link", v7);
v6.addEdge("link", v4);
v6.addEdge("link", v5);
v6.addEdge("link", v7);
v7.addEdge("link", v4);
v7.addEdge("link", v5);
v7.addEdge("link", v6);
}
use of com.baidu.hugegraph.structure.graph.Vertex in project hugegraph-computer by hugegraph.
the class RingsDetectionTest method setup.
@BeforeClass
public static void setup() {
clearAll();
HugeClient client = client();
SchemaManager schema = client.schema();
schema.vertexLabel("user").useCustomizeStringId().ifNotExist().create();
schema.edgeLabel("know").sourceLabel("user").targetLabel("user").ifNotExist().create();
GraphManager graph = client.graph();
Vertex vA = graph.addVertex(T.label, "user", T.id, "A");
Vertex vB = graph.addVertex(T.label, "user", T.id, "B");
Vertex vC = graph.addVertex(T.label, "user", T.id, "C");
Vertex vD = graph.addVertex(T.label, "user", T.id, "D");
Vertex vE = graph.addVertex(T.label, "user", T.id, "E");
vA.addEdge("know", vB);
vA.addEdge("know", vC);
vA.addEdge("know", vD);
vB.addEdge("know", vC);
vC.addEdge("know", vA);
vC.addEdge("know", vE);
vD.addEdge("know", vA);
vD.addEdge("know", vC);
vE.addEdge("know", vD);
RingsDetectionTestOutput.EXPECT_RINGS = EXPECT_RINGS;
}
use of com.baidu.hugegraph.structure.graph.Vertex in project hugegraph-computer by hugegraph.
the class MockWorkerInputManager method loadVertexInputSplitData.
public int loadVertexInputSplitData() {
if (this.vertexInputSplit == null) {
throw new ComputerException("Should fetch vertex input split " + "meta before load");
}
if (this.vertexInputSplit.equals(InputSplit.END_SPLIT)) {
throw new ComputerException("Can't load vertex input split data, " + "because it has been exhausted");
}
VertexFetcher vertexFetcher = this.fetcher.vertexFetcher();
vertexFetcher.prepareLoadInputSplit(this.vertexInputSplit);
int count = 0;
while (vertexFetcher.hasNext()) {
Vertex vertex = vertexFetcher.next();
// Write vertex to buffer
Assert.assertNotNull(vertex);
count++;
}
return count;
}
use of com.baidu.hugegraph.structure.graph.Vertex in project hugegraph-computer by hugegraph.
the class TaskManager method submitBatch.
public void submitBatch(List<Vertex> batch) {
try {
this.batchSemaphore.acquire();
} catch (InterruptedException e) {
throw new WriteBackException("Interrupted while waiting to submit batch", e);
}
InsertTask task = new BatchInsertTask(this.config, this.client, batch, this.loadSummary);
CompletableFuture.runAsync(task, this.batchService).exceptionally(e -> {
LOG.warn("Batch insert error, try single insert", e);
this.submitInSingle(batch);
return null;
}).whenComplete((r, e) -> this.batchSemaphore.release());
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class GraphService method buildVertex.
private Vertex buildVertex(int connId, VertexEntity entity) {
Vertex vertex = new Vertex(entity.getLabel());
VertexLabelEntity vl = this.vlService.get(entity.getLabel(), connId);
// Allowed front-end always pass id
if (vl.getIdStrategy().isCustomize()) {
Object vid = this.convertVertexId(vl.getIdStrategy(), entity.getId());
vertex.id(vid);
}
this.fillProperties(connId, vl, vertex, entity.getProperties());
return vertex;
}
Aggregations