use of org.neo4j.graphdb.traversal.TraversalBranch in project neo4j-mobile-android by neo4j-contrib.
the class PostorderDepthFirstSelector method next.
public TraversalBranch next() {
TraversalBranch result = null;
while (result == null) {
if (current == null) {
return null;
}
TraversalBranch next = current.next();
if (next != null) {
current = next;
} else {
result = current;
current = current.parent();
}
}
return result;
}
use of org.neo4j.graphdb.traversal.TraversalBranch in project neo4j-mobile-android by neo4j-contrib.
the class PreorderBreadthFirstSelector method next.
public TraversalBranch next() {
TraversalBranch result = null;
while (result == null) {
TraversalBranch next = current.next();
if (next != null) {
queue.add(next);
result = next;
} else {
current = queue.poll();
if (current == null) {
return null;
}
}
}
return result;
}
use of org.neo4j.graphdb.traversal.TraversalBranch in project neo4j by neo4j.
the class TraversalBranchImpl method relationships.
@Override
public Iterable<Relationship> relationships() {
LinkedList<Relationship> relationships = new LinkedList<>();
TraversalBranch branch = this;
while (branch.length() > 0) {
relationships.addFirst(branch.lastRelationship());
branch = branch.parent();
}
return relationships;
}
use of org.neo4j.graphdb.traversal.TraversalBranch in project neo4j by neo4j.
the class TraversalBranchImpl method nodes.
@Override
public Iterable<Node> nodes() {
LinkedList<Node> nodes = new LinkedList<>();
TraversalBranch branch = this;
while (branch.length() > 0) {
nodes.addFirst(branch.endNode());
branch = branch.parent();
}
nodes.addFirst(branch.endNode());
return nodes;
}
use of org.neo4j.graphdb.traversal.TraversalBranch in project neo4j by neo4j.
the class TraversalBranchImpl method hashCode.
@Override
public int hashCode() {
TraversalBranch branch = this;
int hashCode = 1;
while (branch.length() > 0) {
Relationship relationship = branch.lastRelationship();
hashCode = 31 * hashCode + relationship.hashCode();
branch = branch.parent();
}
if (hashCode == 1) {
hashCode = endNode().hashCode();
}
return hashCode;
}
Aggregations