Search in sources :

Example 86 with Vertex

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);
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphManager(com.baidu.hugegraph.driver.GraphManager) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) BeforeClass(org.junit.BeforeClass)

Example 87 with Vertex

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;
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphManager(com.baidu.hugegraph.driver.GraphManager) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) BeforeClass(org.junit.BeforeClass)

Example 88 with Vertex

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;
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException)

Example 89 with Vertex

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());
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) ComputerOptions(com.baidu.hugegraph.computer.core.config.ComputerOptions) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) WriteBackException(com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException) ExecutorUtil(com.baidu.hugegraph.util.ExecutorUtil) CompletableFuture(java.util.concurrent.CompletableFuture) Vertex(com.baidu.hugegraph.structure.graph.Vertex) Config(com.baidu.hugegraph.computer.core.config.Config) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Log(com.baidu.hugegraph.util.Log) Printer(com.baidu.hugegraph.computer.core.output.hg.metrics.Printer) HugeClientBuilder(com.baidu.hugegraph.driver.HugeClientBuilder) LoadSummary(com.baidu.hugegraph.computer.core.output.hg.metrics.LoadSummary) ExecutorService(java.util.concurrent.ExecutorService) WriteBackException(com.baidu.hugegraph.computer.core.output.hg.exceptions.WriteBackException)

Example 90 with Vertex

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;
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) VertexLabelEntity(com.baidu.hugegraph.entity.schema.VertexLabelEntity)

Aggregations

Vertex (com.baidu.hugegraph.structure.graph.Vertex)165 Test (org.junit.Test)110 Edge (com.baidu.hugegraph.structure.graph.Edge)33 HugeClient (com.baidu.hugegraph.driver.HugeClient)22 ArrayList (java.util.ArrayList)21 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)18 BaseClientTest (com.baidu.hugegraph.BaseClientTest)17 BeforeClass (org.junit.BeforeClass)17 GraphManager (com.baidu.hugegraph.driver.GraphManager)14 BatchVertexRequest (com.baidu.hugegraph.structure.graph.BatchVertexRequest)13 Path (com.baidu.hugegraph.structure.graph.Path)11 Result (com.baidu.hugegraph.structure.gremlin.Result)10 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)10 List (java.util.List)10 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)9 ImmutableList (com.google.common.collect.ImmutableList)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 Map (java.util.Map)6 RestResult (com.baidu.hugegraph.rest.RestResult)5 PathsWithVertices (com.baidu.hugegraph.structure.traverser.PathsWithVertices)5