本文整理了Java中org.vertexium.Graph.getEdges()
方法的一些代码示例,展示了Graph.getEdges()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getEdges()
方法的具体详情如下:
包路径:org.vertexium.Graph
类名称:Graph
方法名:getEdges
[英]Gets all edges on the graph matching the given ids.
[中]获取图上与给定ID匹配的所有边。
代码示例来源:origin: org.vertexium/vertexium-core
public static Iterable<EdgeVertexPair> getEdgeVertexPairs(
Graph graph,
String sourceVertexId,
Iterable<EdgeInfo> edgeInfos,
FetchHints fetchHints,
Long endTime,
Authorizations authorizations
) {
Set<String> edgeIdsToFetch = new HashSet<>();
Set<String> vertexIdsToFetch = new HashSet<>();
for (EdgeInfo edgeInfo : edgeInfos) {
edgeIdsToFetch.add(edgeInfo.getEdgeId());
vertexIdsToFetch.add(edgeInfo.getVertexId());
}
final Map<String, Vertex> vertices = IterableUtils.toMapById(graph.getVertices(vertexIdsToFetch, fetchHints, endTime, authorizations));
Iterable<Edge> edges = graph.getEdges(edgeIdsToFetch, fetchHints, endTime, authorizations);
return new ConvertingIterable<Edge, EdgeVertexPair>(edges) {
@Override
protected EdgeVertexPair convert(Edge edge) {
String otherVertexId = edge.getOtherVertexId(sourceVertexId);
Vertex otherVertex = vertices.get(otherVertexId);
if (otherVertex == null) {
throw new VertexiumException("Found an edge " + edge.getId() + ", but could not find the vertex on the other end: " + otherVertexId);
}
return new EdgeVertexPair(edge, otherVertex);
}
};
}
}
代码示例来源:origin: org.visallo/visallo-web
/**
* This is overridable so web plugins can modify the resulting set of edges.
*/
@SuppressWarnings("UnusedParameters")
protected ClientApiEdgeMultipleResponse getEdges(
HttpServletRequest request,
String workspaceId,
Iterable<String> edgeIds,
Authorizations authorizations
) {
ClientApiEdgeMultipleResponse edgeResult = new ClientApiEdgeMultipleResponse();
Iterable<Edge> edges = graph.getEdges(edgeIds, FetchHint.ALL, authorizations);
for (Edge e : edges) {
ClientApiEdge clientApiEdge = ClientApiConverter.toClientApiEdge(e, workspaceId);
edgeResult.getEdges().add(clientApiEdge);
}
return edgeResult;
}
}
代码示例来源:origin: visallo/vertexium
public static Iterable<EdgeVertexPair> getEdgeVertexPairs(
Graph graph,
String sourceVertexId,
Iterable<EdgeInfo> edgeInfos,
FetchHints fetchHints,
Long endTime,
Authorizations authorizations
) {
Set<String> edgeIdsToFetch = new HashSet<>();
Set<String> vertexIdsToFetch = new HashSet<>();
for (EdgeInfo edgeInfo : edgeInfos) {
edgeIdsToFetch.add(edgeInfo.getEdgeId());
vertexIdsToFetch.add(edgeInfo.getVertexId());
}
final Map<String, Vertex> vertices = IterableUtils.toMapById(graph.getVertices(vertexIdsToFetch, fetchHints, endTime, authorizations));
Iterable<Edge> edges = graph.getEdges(edgeIdsToFetch, fetchHints, endTime, authorizations);
return new ConvertingIterable<Edge, EdgeVertexPair>(edges) {
@Override
protected EdgeVertexPair convert(Edge edge) {
String otherVertexId = edge.getOtherVertexId(sourceVertexId);
Vertex otherVertex = vertices.get(otherVertexId);
if (otherVertex == null) {
throw new VertexiumException("Found an edge " + edge.getId() + ", but could not find the vertex on the other end: " + otherVertexId);
}
return new EdgeVertexPair(edge, otherVertex);
}
};
}
}
代码示例来源:origin: org.vertexium/vertexium-blueprints
@Override
public Iterable<Edge> getEdges() {
final Authorizations authorizations = getAuthorizationsProvider().getAuthorizations();
return new ConvertingIterable<org.vertexium.Edge, Edge>(getGraph().getEdges(getFetchHints(), authorizations)) {
@Override
protected Edge convert(org.vertexium.Edge edge) {
return VertexiumBlueprintsEdge.create(VertexiumBlueprintsGraph.this, edge, authorizations);
}
};
}
代码示例来源:origin: org.vertexium/vertexium-blueprints
@Override
public Iterable<Edge> edges() {
if (!hasFilter) {
return VertexiumBlueprintsConvert.toBlueprintsEdges(graph, graph.getGraph().getEdges(graph.getFetchHints(), authorizations), authorizations);
}
Iterable<org.vertexium.Edge> edges = q.edges(graph.getFetchHints());
return VertexiumBlueprintsConvert.toBlueprintsEdges(graph, edges, authorizations);
}
代码示例来源:origin: org.vertexium/vertexium-elasticsearch-singledocument
Iterable<? extends VertexiumObject> edges = getGraph().getEdges(ids.getEdgeIds(), fetchHints, filterParameters.getAuthorizations());
items.add(edges);
代码示例来源:origin: org.vertexium/vertexium-elasticsearch2
Iterable<? extends VertexiumObject> edges = getGraph().getEdges(ids.getEdgeIds(), fetchHints, filterParameters.getAuthorizations());
items.add(edges);
代码示例来源:origin: visallo/vertexium
@SuppressWarnings("unchecked")
private <T extends Element> Iterable<T> getIterableFromElementType(ElementType elementType, FetchHints fetchHints) throws VertexiumException {
switch (elementType) {
case VERTEX:
return (Iterable<T>) getGraph().getVertices(fetchHints, getParameters().getAuthorizations());
case EDGE:
return (Iterable<T>) getGraph().getEdges(fetchHints, getParameters().getAuthorizations());
default:
throw new VertexiumException("Unexpected element type: " + elementType);
}
}
代码示例来源:origin: org.vertexium/vertexium-core
@SuppressWarnings("unchecked")
private <T extends Element> Iterable<T> getIterableFromElementType(ElementType elementType, FetchHints fetchHints) throws VertexiumException {
switch (elementType) {
case VERTEX:
return (Iterable<T>) getGraph().getVertices(fetchHints, getParameters().getAuthorizations());
case EDGE:
return (Iterable<T>) getGraph().getEdges(fetchHints, getParameters().getAuthorizations());
default:
throw new VertexiumException("Unexpected element type: " + elementType);
}
}
代码示例来源:origin: org.visallo/visallo-core
@Traced
protected Iterable<Edge> findModifiedEdges(
final Workspace workspace,
List<WorkspaceEntity> workspaceEntities,
boolean includeHidden,
User user
) {
Authorizations systemAuthorizations = getAuthorizationRepository().getGraphAuthorizations(
user,
VisalloVisibility.SUPER_USER_VISIBILITY_STRING,
workspace.getWorkspaceId()
);
Iterable<Vertex> vertices = stream(WorkspaceEntity.toVertices(workspaceEntities, getGraph(), systemAuthorizations))
.filter(Objects::nonNull)
.collect(Collectors.toList());
Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(
user,
VISIBILITY_STRING,
workspace.getWorkspaceId()
);
Iterable<String> edgeIds = getGraph().findRelatedEdgeIdsForVertices(vertices, authorizations);
return getGraph().getEdges(
edgeIds,
includeHidden ? FetchHint.ALL_INCLUDING_HIDDEN : FetchHint.ALL,
authorizations
);
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testGetVertexAtASpecificTimeInHistory() {
Date time25 = createDate(2015, 4, 6, 16, 15, 0);
Date time30 = createDate(2015, 4, 6, 16, 16, 0);
Metadata metadata = Metadata.create();
Vertex v1 = graph.prepareVertex("v1", time25.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 25, metadata, time25.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
Vertex v2 = graph.prepareVertex("v2", time25.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 20, metadata, time25.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, time30.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareVertex("v1", time30.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 30, metadata, time30.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareVertex("v3", time30.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 35, metadata, time30.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.flush();
// verify current versions
assertEquals(30, graph.getVertex("v1", AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertEquals(20, graph.getVertex("v2", AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertEquals(35, graph.getVertex("v3", AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
// verify old version
assertEquals(25, graph.getVertex("v1", graph.getDefaultFetchHints(), time25.getTime(), AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertNull("v3 should not exist at time25", graph.getVertex("v3", graph.getDefaultFetchHints(), time25.getTime(), AUTHORIZATIONS_A));
assertEquals("e1 should not exist", 0, count(graph.getEdges(graph.getDefaultFetchHints(), time25.getTime(), AUTHORIZATIONS_A)));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testGetVertexAtASpecificTimeInHistory() {
Date time25 = createDate(2015, 4, 6, 16, 15, 0);
Date time30 = createDate(2015, 4, 6, 16, 16, 0);
Metadata metadata = Metadata.create();
Vertex v1 = graph.prepareVertex("v1", time25.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 25, metadata, time25.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
Vertex v2 = graph.prepareVertex("v2", time25.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 20, metadata, time25.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareEdge("e1", v1, v2, LABEL_LABEL1, time30.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareVertex("v1", time30.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 30, metadata, time30.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.prepareVertex("v3", time30.getTime(), VISIBILITY_A)
.addPropertyValue("", "age", 35, metadata, time30.getTime(), VISIBILITY_A)
.save(AUTHORIZATIONS_A);
graph.flush();
// verify current versions
assertEquals(30, graph.getVertex("v1", AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertEquals(20, graph.getVertex("v2", AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertEquals(35, graph.getVertex("v3", AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
// verify old version
assertEquals(25, graph.getVertex("v1", graph.getDefaultFetchHints(), time25.getTime(), AUTHORIZATIONS_A).getPropertyValue("", "age"));
assertNull("v3 should not exist at time25", graph.getVertex("v3", graph.getDefaultFetchHints(), time25.getTime(), AUTHORIZATIONS_A));
assertEquals("e1 should not exist", 0, count(graph.getEdges(graph.getDefaultFetchHints(), time25.getTime(), AUTHORIZATIONS_A)));
}
代码示例来源:origin: org.vertexium/vertexium-core
@Override
protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints fetchHints) {
Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations());
Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations());
Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations());
return extendedData(fetchHints, new JoinIterable<>(vertices, edges));
}
代码示例来源:origin: visallo/vertexium
@Test
public void testDeleteEdge() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
Edge addedEdge = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
try {
graph.deleteEdge("e1", AUTHORIZATIONS_B);
} catch (NullPointerException e) {
// expected
}
Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
graph.deleteEdge("e1", AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(0, count(graph.getEdges(AUTHORIZATIONS_A)));
v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
Assert.assertEquals(0, count(v1.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
Assert.assertEquals(0, count(v2.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
graph.flush();
assertEvents(
new AddVertexEvent(graph, v1),
new AddVertexEvent(graph, v2),
new AddEdgeEvent(graph, addedEdge),
new DeleteEdgeEvent(graph, addedEdge)
);
}
代码示例来源:origin: org.vertexium/vertexium-test
@Test
public void testDeleteEdge() {
Vertex v1 = graph.addVertex("v1", VISIBILITY_A, AUTHORIZATIONS_A);
Vertex v2 = graph.addVertex("v2", VISIBILITY_A, AUTHORIZATIONS_A);
Edge addedEdge = graph.addEdge("e1", v1, v2, LABEL_LABEL1, VISIBILITY_A, AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
try {
graph.deleteEdge("e1", AUTHORIZATIONS_B);
} catch (NullPointerException e) {
// expected
}
Assert.assertEquals(1, count(graph.getEdges(AUTHORIZATIONS_A)));
graph.deleteEdge("e1", AUTHORIZATIONS_A);
graph.flush();
Assert.assertEquals(0, count(graph.getEdges(AUTHORIZATIONS_A)));
v1 = graph.getVertex("v1", AUTHORIZATIONS_A);
Assert.assertEquals(0, count(v1.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
v2 = graph.getVertex("v2", AUTHORIZATIONS_A);
Assert.assertEquals(0, count(v2.getVertices(Direction.BOTH, AUTHORIZATIONS_A)));
graph.flush();
assertEvents(
new AddVertexEvent(graph, v1),
new AddVertexEvent(graph, v2),
new AddEdgeEvent(graph, addedEdge),
new DeleteEdgeEvent(graph, addedEdge)
);
}
代码示例来源:origin: visallo/vertexium
@Override
protected QueryResultsIterable<? extends VertexiumObject> extendedData(FetchHints fetchHints) {
Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations());
Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations());
Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations());
return extendedData(fetchHints, new JoinIterable<>(vertices, edges));
}
代码示例来源:origin: visallo/vertexium
@Override
public QueryResultsIterable<Edge> edges(FetchHints fetchHints) {
Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations());
Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations());
Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations());
return new DefaultGraphQueryIterableWithAggregations<>(getParameters(), edges, true, true, true, getAggregations());
}
代码示例来源:origin: org.visallo/visallo-web-structured-ingest-core
List<Edge> edges = Lists.newArrayList(getGraph().getEdges(authorizations));
assertEquals("Found the source and created edges", 3, edges.size());
assertTrue("Found the edge", edges.stream().anyMatch(edge -> edge.getLabel().equals(EDGE_LABEL)));
代码示例来源:origin: org.vertexium/vertexium-core
@Override
public QueryResultsIterable<Edge> edges(FetchHints fetchHints) {
Iterable<Vertex> vertices = getGraph().getVertices(IterableUtils.toIterable(getVertexIds()), fetchHints, getParameters().getAuthorizations());
Iterable<String> edgeIds = new VerticesToEdgeIdsIterable(vertices, getParameters().getAuthorizations());
Iterable<Edge> edges = getGraph().getEdges(edgeIds, fetchHints, getParameters().getAuthorizations());
return new DefaultGraphQueryIterableWithAggregations<>(getParameters(), edges, true, true, true, getAggregations());
}
代码示例来源:origin: org.vertexium/vertexium-test
graph.flush();
assertEquals(1, count(graph.getVertices(AUTHORIZATIONS_A)));
assertEquals(0, count(graph.getEdges(AUTHORIZATIONS_A)));
assertEquals(0, count(graph.query(AUTHORIZATIONS_A).has("name1", "value1").vertices()));
内容来源于网络,如有侵权,请联系作者删除!