use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class OSQLFunctionShortestPath method walkLeft.
protected List<ORID> walkLeft(final OSQLFunctionShortestPath.OShortestPathContext ctx) {
ArrayDeque<OrientVertex> nextLevelQueue = new ArrayDeque<OrientVertex>();
while (!ctx.queueLeft.isEmpty()) {
ctx.current = ctx.queueLeft.poll();
Iterable<Vertex> neighbors;
if (ctx.edgeType == null) {
neighbors = ctx.current.getVertices(ctx.directionLeft);
} else {
neighbors = ctx.current.getVertices(ctx.directionLeft, ctx.edgeTypeParam);
}
for (Vertex neighbor : neighbors) {
final OrientVertex v = (OrientVertex) neighbor;
final ORID neighborIdentity = v.getIdentity();
if (ctx.rightVisited.contains(neighborIdentity)) {
ctx.previouses.put(neighborIdentity, ctx.current.getIdentity());
return computePath(ctx.previouses, ctx.nexts, neighborIdentity);
}
if (!ctx.leftVisited.contains(neighborIdentity)) {
ctx.previouses.put(neighborIdentity, ctx.current.getIdentity());
nextLevelQueue.offer(v);
ctx.leftVisited.add(neighborIdentity);
}
}
}
ctx.queueLeft = nextLevelQueue;
return null;
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class OSQLFunctionShortestPath method walkRight.
protected List<ORID> walkRight(final OSQLFunctionShortestPath.OShortestPathContext ctx) {
final ArrayDeque<OrientVertex> nextLevelQueue = new ArrayDeque<OrientVertex>();
while (!ctx.queueRight.isEmpty()) {
ctx.currentRight = ctx.queueRight.poll();
Iterable<Vertex> neighbors;
if (ctx.edgeType == null) {
neighbors = ctx.currentRight.getVertices(ctx.directionRight);
} else {
neighbors = ctx.currentRight.getVertices(ctx.directionRight, ctx.edgeTypeParam);
}
for (Vertex neighbor : neighbors) {
final OrientVertex v = (OrientVertex) neighbor;
final ORID neighborIdentity = v.getIdentity();
if (ctx.leftVisited.contains(neighborIdentity)) {
ctx.nexts.put(neighborIdentity, ctx.currentRight.getIdentity());
return computePath(ctx.previouses, ctx.nexts, neighborIdentity);
}
if (!ctx.rightVisited.contains(neighborIdentity)) {
ctx.nexts.put(neighborIdentity, ctx.currentRight.getIdentity());
nextLevelQueue.offer(v);
ctx.rightVisited.add(neighborIdentity);
}
}
}
ctx.queueRight = nextLevelQueue;
return null;
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class OSQLFunctionHeuristicPathFinderAbstract method getNeighbors.
protected Set<OrientVertex> getNeighbors(final OrientVertex node) {
context.incrementVariable("getNeighbors");
final Set<OrientVertex> neighbors = new HashSet<OrientVertex>();
if (node != null) {
for (Vertex v : node.getVertices(paramDirection, paramEdgeTypeNames)) {
final OrientVertex ov = (OrientVertex) v;
if (ov != null)
neighbors.add(ov);
}
}
return neighbors;
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class TestFailOperationOnRemovedElement method testAddEdgeOnRemovedVertex.
@Test(expected = ORecordNotFoundException.class)
public void testAddEdgeOnRemovedVertex() {
Vertex v = grap.addVertex(null);
Vertex v1 = grap.addVertex(null);
grap.commit();
v.remove();
v.addEdge("test", v1);
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class TestFailOperationOnRemovedElement method testAddEdgeToRemovedVertex.
@Test(expected = ORecordNotFoundException.class)
public void testAddEdgeToRemovedVertex() {
Vertex v = grap.addVertex(null);
Vertex v1 = grap.addVertex(null);
grap.commit();
v1.remove();
v.addEdge("test", v1);
}
Aggregations