use of com.baidu.hugegraph.driver.SchemaManager in project hugegraph-computer by hugegraph.
the class RingsDetectionWithFilterTest method setup.
@BeforeClass
public static void setup() {
clearAll();
HugeClient client = client();
SchemaManager schema = client.schema();
schema.propertyKey("weight").asInt().ifNotExist().create();
schema.vertexLabel("user").properties("weight").useCustomizeStringId().ifNotExist().create();
schema.edgeLabel("know").sourceLabel("user").targetLabel("user").properties("weight").ifNotExist().create();
GraphManager graph = client.graph();
Vertex vA = graph.addVertex(T.label, "user", T.id, "A", "weight", 1);
Vertex vB = graph.addVertex(T.label, "user", T.id, "B", "weight", 1);
Vertex vC = graph.addVertex(T.label, "user", T.id, "C", "weight", 1);
Vertex vD = graph.addVertex(T.label, "user", T.id, "D", "weight", 1);
Vertex vE = graph.addVertex(T.label, "user", T.id, "E", "weight", 3);
vA.addEdge("know", vB, "weight", 1);
vA.addEdge("know", vC, "weight", 1);
vA.addEdge("know", vD, "weight", 1);
vB.addEdge("know", vA, "weight", 2);
vB.addEdge("know", vC, "weight", 1);
vB.addEdge("know", vE, "weight", 1);
vC.addEdge("know", vA, "weight", 1);
vC.addEdge("know", vB, "weight", 1);
vC.addEdge("know", vD, "weight", 1);
vD.addEdge("know", vC, "weight", 1);
vD.addEdge("know", vE, "weight", 1);
vE.addEdge("know", vC, "weight", 1);
RingsDetectionTestOutput.EXPECT_RINGS = EXPECT_RINGS;
}
use of com.baidu.hugegraph.driver.SchemaManager 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.SchemaManager 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.SchemaManager 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.SchemaManager in project incubator-hugegraph-toolchain by apache.
the class SchemaService method convertIndexLabels.
public static List<IndexLabel> convertIndexLabels(List<PropertyIndex> entities, HugeClient client, boolean isVertex, String baseValue) {
if (CollectionUtils.isEmpty(entities)) {
return Collections.emptyList();
}
List<IndexLabel> indexLabels = new ArrayList<>(entities.size());
SchemaManager schema = client.schema();
for (PropertyIndex index : entities) {
String[] fields = toStringArray(index.getFields());
IndexLabel indexLabel = schema.indexLabel(index.getName()).on(isVertex, baseValue).indexType(index.getType()).by(fields).build();
indexLabels.add(indexLabel);
}
return indexLabels;
}
Aggregations