本文整理了Java中org.vertexium.Graph.addVertex()
方法的一些代码示例,展示了Graph.addVertex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.addVertex()
方法的具体详情如下:
包路径:org.vertexium.Graph
类名称:Graph
方法名:addVertex
[英]Adds a vertex to the graph.
[中]将顶点添加到图形中。
代码示例来源:origin: visallo/vertexium
private List<Vertex> getVertices(long count) {
List<Vertex> vertices = new ArrayList<>();
for (int i = 0; i < count; i++) {
Vertex vertex = graph.addVertex(Integer.toString(i), VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
vertices.add(vertex);
}
return vertices;
}
代码示例来源:origin: org.vertexium/vertexium-test
private List<Vertex> getVertices(long count) {
List<Vertex> vertices = new ArrayList<>();
for (int i = 0; i < count; i++) {
Vertex vertex = graph.addVertex(Integer.toString(i), VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
vertices.add(vertex);
}
return vertices;
}
代码示例来源:origin: visallo/vertexium
@Test
public void testGetVertexWithBadAuthorizations() {
graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_A);
graph.flush();
try {
graph.getVertex("v1", AUTHORIZATIONS_BAD);
throw new RuntimeException("Should throw " + SecurityVertexiumException.class.getSimpleName());
} catch (SecurityVertexiumException ex) {
// ok
}
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGetVertexWithBadAuthorizations() {
graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_A);
graph.flush();
try {
graph.getVertex("v1", AUTHORIZATIONS_BAD);
throw new RuntimeException("Should throw " + SecurityVertexiumException.class.getSimpleName());
} catch (SecurityVertexiumException ex) {
// ok
}
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testEmptyPropertyMutation() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL);
v1.prepareMutation().save(AUTHORIZATIONS_ALL);
}
代码示例来源:origin: visallo/vertexium
@Test
public void testEmptyPropertyMutation() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_ALL);
v1.prepareMutation().save(AUTHORIZATIONS_ALL);
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGraphQueryForEdgesUsingInOrOutVertexId() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
Vertex v3 = graph.addVertex("v3", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.addEdge("e2", v1, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.addEdge("e3", v2, v3, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
QueryResultsIterable<Edge> edges = graph.query(AUTHORIZATIONS_A)
.has(Edge.IN_OR_OUT_VERTEX_ID_PROPERTY_NAME, "v1")
.edges();
assertEdgeIdsAnyOrder(edges, "e1", "e2");
}
代码示例来源:origin: visallo/vertexium
@Test
public void testGetCounts() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
assertEquals(2, graph.getVertexCount(AUTHORIZATIONS_A));
assertEquals(1, graph.getEdgeCount(AUTHORIZATIONS_A));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGetCounts() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
assertEquals(2, graph.getVertexCount(AUTHORIZATIONS_A));
assertEquals(1, graph.getEdgeCount(AUTHORIZATIONS_A));
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGetVerticesWithPrefix() {
graph.addVertex("a", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
graph.addVertex("aa", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
graph.addVertex("az", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
graph.addVertex("b", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
graph.flush();
List<Vertex> vertices = sortById(toList(graph.getVerticesWithPrefix("a", AUTHORIZATIONS_ALL)));
assertVertexIds(vertices, "a", "aa", "az");
vertices = sortById(toList(graph.getVerticesWithPrefix("b", AUTHORIZATIONS_ALL)));
assertVertexIds(vertices, "b");
vertices = sortById(toList(graph.getVerticesWithPrefix("c", AUTHORIZATIONS_ALL)));
assertVertexIds(vertices);
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGetSingleVertexWithSameRowPrefix() {
graph.addVertex("prefix", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
graph.addVertex("prefixA", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
graph.flush();
Vertex v = graph.getVertex("prefix", AUTHORIZATIONS_EMPTY);
assertEquals("prefix", v.getId());
v = graph.getVertex("prefixA", AUTHORIZATIONS_EMPTY);
assertEquals("prefixA", v.getId());
}
代码示例来源:origin: visallo/vertexium
@Test
public void testGetSingleVertexWithSameRowPrefix() {
graph.addVertex("prefix", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
graph.addVertex("prefixA", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
graph.flush();
Vertex v = graph.getVertex("prefix", AUTHORIZATIONS_EMPTY);
assertEquals("prefix", v.getId());
v = graph.getVertex("prefixA", AUTHORIZATIONS_EMPTY);
assertEquals("prefixA", v.getId());
}
代码示例来源:origin: visallo/vertexium
@Test(expected = VertexiumNotSupportedException.class)
public void testRetrievingVerticesFromElasticsearchEdge() {
graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
QueryResultsIterable<Edge> edges = graph.query(AUTHORIZATIONS_A)
.edges(FetchHints.NONE);
assertResultsCount(1, 1, edges);
toList(edges).get(0).getVertices(AUTHORIZATIONS_A);
}
代码示例来源:origin: org.vertexium/vertexium-blueprints
@Override
public Vertex addVertex(Object id) {
Visibility visibility = getVisibilityProvider().getVisibilityForVertex(VertexiumBlueprintsConvert.idToString(id));
Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
return VertexiumBlueprintsVertex.create(this, getGraph().addVertex(VertexiumBlueprintsConvert.idToString(id), visibility, authorizations), authorizations);
}
代码示例来源:origin: visallo/vertexium
@Test
public void testQueryReturningElasticsearchVertex() {
graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
graph.addVertex("v2", VISIBILITY_B, AUTHORIZATIONS_B);
graph.addEdge("e1", "v1", "v2", LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
QueryResultsIterable<Vertex> vertices = graph.query(AUTHORIZATIONS_B)
.vertices(FetchHints.NONE);
assertResultsCount(1, 1, vertices);
Vertex vertex = toList(vertices).get(0);
assertEquals("v2", vertex.getId());
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testDeleteVertex() {
graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A)));
graph.deleteVertex("v1", AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A)));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testDeleteVertex() {
graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A)));
graph.deleteVertex("v1", AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(0, count(graph.getVertices(AUTHORIZATIONS_A)));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testBlankVisibilityString() {
Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
assertNotNull(v);
assertEquals("v1", v.getId());
graph.flush();
v = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
assertNotNull(v);
assertEquals("v1", v.getId());
assertEquals(VISIBILITY_EMPTY, v.getVisibility());
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testBlankVisibilityString() {
Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_EMPTY);
assertNotNull(v);
assertEquals("v1", v.getId());
graph.flush();
v = graph.getVertex("v1", AUTHORIZATIONS_EMPTY);
assertNotNull(v);
assertEquals("v1", v.getId());
assertEquals(VISIBILITY_EMPTY, v.getVisibility());
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testElementMutationDoesntChangeObjectUntilSave() {
Vertex v = graph.addVertex("v1", VISIBILITY_EMPTY, AUTHORIZATIONS_ALL);
v.setProperty("prop1", "value1-1", VISIBILITY_A, AUTHORIZATIONS_ALL);
graph.flush();
ElementMutation<Vertex> m = v.prepareMutation()
.setProperty("prop1", "value1-2", VISIBILITY_A)
.setProperty("prop2", "value2-2", VISIBILITY_A);
Assert.assertEquals(1, count(v.getProperties()));
assertEquals("value1-1", v.getPropertyValue("prop1"));
v = m.save(AUTHORIZATIONS_A_AND_B);
Assert.assertEquals(2, count(v.getProperties()));
assertEquals("value1-2", v.getPropertyValue("prop1"));
assertEquals("value2-2", v.getPropertyValue("prop2"));
}
内容来源于网络,如有侵权,请联系作者删除!