Search in sources :

Example 1 with GraphManager

use of com.baidu.hugegraph.driver.GraphManager in project incubator-hugegraph-toolchain by apache.

the class NeighborRankApiTest method initNeighborRankGraph.

@BeforeClass
public static void initNeighborRankGraph() {
    GraphManager graph = graph();
    SchemaManager schema = schema();
    schema.propertyKey("name").asText().ifNotExist().create();
    schema.vertexLabel("person").properties("name").useCustomizeStringId().ifNotExist().create();
    schema.vertexLabel("movie").properties("name").useCustomizeStringId().ifNotExist().create();
    schema.edgeLabel("follow").sourceLabel("person").targetLabel("person").ifNotExist().create();
    schema.edgeLabel("like").sourceLabel("person").targetLabel("movie").ifNotExist().create();
    schema.edgeLabel("directedBy").sourceLabel("movie").targetLabel("person").ifNotExist().create();
    Vertex O = graph.addVertex(T.label, "person", T.id, "O", "name", "O");
    Vertex A = graph.addVertex(T.label, "person", T.id, "A", "name", "A");
    Vertex B = graph.addVertex(T.label, "person", T.id, "B", "name", "B");
    Vertex C = graph.addVertex(T.label, "person", T.id, "C", "name", "C");
    Vertex D = graph.addVertex(T.label, "person", T.id, "D", "name", "D");
    Vertex E = graph.addVertex(T.label, "movie", T.id, "E", "name", "E");
    Vertex F = graph.addVertex(T.label, "movie", T.id, "F", "name", "F");
    Vertex G = graph.addVertex(T.label, "movie", T.id, "G", "name", "G");
    Vertex H = graph.addVertex(T.label, "movie", T.id, "H", "name", "H");
    Vertex I = graph.addVertex(T.label, "movie", T.id, "I", "name", "I");
    Vertex J = graph.addVertex(T.label, "movie", T.id, "J", "name", "J");
    Vertex K = graph.addVertex(T.label, "person", T.id, "K", "name", "K");
    Vertex L = graph.addVertex(T.label, "person", T.id, "L", "name", "L");
    Vertex M = graph.addVertex(T.label, "person", T.id, "M", "name", "M");
    O.addEdge("follow", A);
    O.addEdge("follow", B);
    O.addEdge("follow", C);
    D.addEdge("follow", O);
    A.addEdge("follow", B);
    A.addEdge("like", E);
    A.addEdge("like", F);
    B.addEdge("like", G);
    B.addEdge("like", H);
    C.addEdge("like", I);
    C.addEdge("like", J);
    E.addEdge("directedBy", K);
    F.addEdge("directedBy", B);
    F.addEdge("directedBy", L);
    G.addEdge("directedBy", M);
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) GraphManager(com.baidu.hugegraph.driver.GraphManager) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) BeforeClass(org.junit.BeforeClass)

Example 2 with GraphManager

use of com.baidu.hugegraph.driver.GraphManager in project incubator-hugegraph-toolchain by apache.

the class GraphService method updateVertex.

public Vertex updateVertex(int connId, VertexEntity entity) {
    HugeClient client = this.client(connId);
    GraphManager graph = client.graph();
    Vertex vertex = this.buildVertex(connId, entity);
    // TODO: client should add updateVertex() method
    return graph.addVertex(vertex);
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphManager(com.baidu.hugegraph.driver.GraphManager)

Example 3 with GraphManager

use of com.baidu.hugegraph.driver.GraphManager in project incubator-hugegraph-toolchain by apache.

the class GraphService method updateEdge.

public Edge updateEdge(int connId, EdgeEntity entity) {
    HugeClient client = this.client(connId);
    GraphManager graph = client.graph();
    EdgeHolder edgeHolder = this.buildEdge(connId, entity);
    // TODO: client should add updateEdge()
    return graph.addEdge(edgeHolder.edge);
}
Also used : HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphManager(com.baidu.hugegraph.driver.GraphManager)

Example 4 with GraphManager

use of com.baidu.hugegraph.driver.GraphManager in project incubator-hugegraph-toolchain by apache.

the class GraphService method addEdge.

public GraphView addEdge(int connId, EdgeEntity entity) {
    HugeClient client = this.client(connId);
    GraphManager graph = client.graph();
    EdgeHolder edgeHolder = this.buildEdge(connId, entity);
    Edge edge = graph.addEdge(edgeHolder.edge);
    Vertex source = edgeHolder.source;
    Vertex target = edgeHolder.target;
    return GraphView.builder().vertices(ImmutableSet.of(source, target)).edges(ImmutableSet.of(edge)).build();
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) HugeClient(com.baidu.hugegraph.driver.HugeClient) GraphManager(com.baidu.hugegraph.driver.GraphManager) Edge(com.baidu.hugegraph.structure.graph.Edge)

Example 5 with GraphManager

use of com.baidu.hugegraph.driver.GraphManager in project incubator-hugegraph-toolchain by apache.

the class RestResultTest method init.

@BeforeClass
public static void init() {
    graphManager = Mockito.mock(GraphManager.class);
    SimpleModule module = new SimpleModule();
    module.addDeserializer(Path.class, new PathDeserializer());
    RestResult.registerModule(module);
}
Also used : PathDeserializer(com.baidu.hugegraph.serializer.PathDeserializer) GraphManager(com.baidu.hugegraph.driver.GraphManager) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) BeforeClass(org.junit.BeforeClass)

Aggregations

GraphManager (com.baidu.hugegraph.driver.GraphManager)16 Vertex (com.baidu.hugegraph.structure.graph.Vertex)14 HugeClient (com.baidu.hugegraph.driver.HugeClient)11 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)11 BeforeClass (org.junit.BeforeClass)8 Edge (com.baidu.hugegraph.structure.graph.Edge)4 GremlinManager (com.baidu.hugegraph.driver.GremlinManager)1 EdgeLabelEntity (com.baidu.hugegraph.entity.schema.EdgeLabelEntity)1 VertexLabelEntity (com.baidu.hugegraph.entity.schema.VertexLabelEntity)1 PathDeserializer (com.baidu.hugegraph.serializer.PathDeserializer)1 Path (com.baidu.hugegraph.structure.graph.Path)1 Result (com.baidu.hugegraph.structure.gremlin.Result)1 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 ArrayList (java.util.ArrayList)1