use of com.baidu.hugegraph.driver.HugeClient in project hugegraph-computer by hugegraph.
the class ClosenessCentralityTest method setup.
@BeforeClass
public static void setup() {
clearAll();
HugeClient client = client();
SchemaManager schema = client.schema();
schema.propertyKey("rate").asInt().ifNotExist().create();
schema.vertexLabel("user").useCustomizeStringId().ifNotExist().create();
schema.edgeLabel("link").sourceLabel("user").targetLabel("user").properties("rate").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");
Vertex vF = graph.addVertex(T.label, "user", T.id, "F");
vA.addEdge("link", vB, "rate", 1);
vB.addEdge("link", vA, "rate", 1);
vB.addEdge("link", vC, "rate", 2);
vC.addEdge("link", vB, "rate", 2);
vB.addEdge("link", vD, "rate", 2);
vD.addEdge("link", vB, "rate", 2);
vC.addEdge("link", vD, "rate", 1);
vD.addEdge("link", vC, "rate", 1);
vC.addEdge("link", vE, "rate", 3);
vE.addEdge("link", vC, "rate", 3);
vD.addEdge("link", vE, "rate", 1);
vE.addEdge("link", vD, "rate", 1);
vD.addEdge("link", vF, "rate", 4);
vF.addEdge("link", vD, "rate", 4);
vE.addEdge("link", vF, "rate", 2);
vF.addEdge("link", vE, "rate", 2);
}
use of com.baidu.hugegraph.driver.HugeClient 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.driver.HugeClient 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.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GraphService method addVertex.
public GraphView addVertex(int connId, VertexEntity entity) {
HugeClient client = this.client(connId);
Vertex vertex = this.buildVertex(connId, entity);
vertex = client.graph().addVertex(vertex);
return GraphView.builder().vertices(ImmutableSet.of(vertex)).edges(ImmutableSet.of()).build();
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class GraphService method buildEdge.
private EdgeHolder buildEdge(int connId, EdgeEntity entity) {
HugeClient client = this.client(connId);
GraphManager graph = client.graph();
EdgeLabelEntity el = this.elService.get(entity.getLabel(), connId);
VertexLabelEntity sourceVl = this.vlService.get(el.getSourceLabel(), connId);
VertexLabelEntity targetVl = this.vlService.get(el.getTargetLabel(), connId);
Object realSourceId = this.convertVertexId(sourceVl.getIdStrategy(), entity.getSourceId());
Object realTargetId = this.convertVertexId(targetVl.getIdStrategy(), entity.getTargetId());
Vertex sourceVertex = graph.getVertex(realSourceId);
Vertex targetVertex = graph.getVertex(realTargetId);
Ex.check(el.getSourceLabel().equals(sourceVertex.label()) && el.getTargetLabel().equals(targetVertex.label()), "graph.edge.link-unmatched-vertex", entity.getLabel(), el.getSourceLabel(), el.getTargetLabel(), sourceVertex.label(), targetVertex.label());
Edge edge = new Edge(entity.getLabel());
edge.source(sourceVertex);
edge.target(targetVertex);
this.fillProperties(connId, el, edge, entity.getProperties());
return new EdgeHolder(edge, sourceVertex, targetVertex);
}
Aggregations