Thanks Micheal,
i have changed my code in this way:
TraversalDescription td = graphDb
.traversalDescription()
.uniqueness(Uniqueness.RELATIONSHIP_PATH)
.expand(new PathExpander<Relationship>() {
@SuppressWarnings("unchecked")
public Iterable<Relationship> expand(final Path path,
BranchState<Relationship> state) {
Iterator<Relationship> it =
path.endNode().getRelationships(Direction.OUTGOING,
RelTypes.MOVES).iterator();
List<Relationship> filteredRels = new ArrayList<Relationship>();
long newStart = start;
if (path.lastRelationship() != null) {
newStart = (Long) path.lastRelationship().getProperty("data_movimento_ts");
}
while (it.hasNext()) {
Relationship rel = (Relationship) it.next();
long dataMovimento = (Long) rel.getProperty("data_movimento_ts");
if (dataMovimento >= newStart && dataMovimento <= end) {
filteredRels.add(rel);
}
}
return filteredRels;
}
public PathExpander<Relationship> reverse() {
// TODO Auto-generated method stub
return null;
}
});
return td.traverse(node);
but the performance still does not improve.
Where am i wrong?
Iis possbile to do something like this in cypher?
I can not give you accurate data because after several minutes the process
is still running so i kill it.
Il giorno lunedì 19 maggio 2014 03:26:01 UTC+2, Michael Hunger ha scritto:
>
> I think instead of evaluating the whole path over and over again, use the
> information that the path up until the currentl point already conforms to
> the specification and rather use a RelationshipExpander/PathExpander, to
> select the next relationships that fulfill that condition:
>
> " if a edge "r" has r.property in [1,10] and r.property = x the next edge
> "r1", of the path, must have r1.property in [x,10] and so on. "
>
> I'd also use primitive longs for start and end to avoid boxing.
>
> Is the measured run the first run of your path finding or a subsequent run?
>
> Michael
>
>
>
> On Sun, May 18, 2014 at 11:57 PM, Andrea Santurbano
> <[email protected]<javascript:>
> > wrote:
>
>> Hi guys,
>> with my colleagues we are comparing two graph databases wich one is neo4j.
>> We have around 100k of nodes and 1m of edges and we need traverse the
>> graph by a start node.
>> While in other db we have no difficult to get the results in few seconds,
>> in neo4j we get several performance issue.
>>
>> Our problem:
>> Given a start node are considered valid all paths that satisfy a
>> condition:
>> Given a range [1, 10]
>> if a edge "r" has r.property in [1,10] and r.property = x the next edge
>> "r1", of the path, must have r1.property in [x,10] and so on...
>>
>> For small ranges the performance of two dbs are comparable...
>>
>> We use the traversal api:
>>
>> private Traverser getFoF(final Node node, boolean isBackward,
>> Long start, Long end) {
>> TraversalDescription td = graphDb
>> .traversalDescription()
>> .order(BranchOrderingPolicies.PREORDER_DEPTH_FIRST)
>> .relationships(RelTypes.MOVES, Direction.OUTGOING)
>> .evaluator(Evaluators.excludeStartPosition())
>> .uniqueness(Uniqueness.RELATIONSHIP_PATH)
>> .evaluator(new PathFilter(start, end));
>> return td.traverse(node);
>> }
>>
>> public class PathFilter implements Evaluator, Predicate {
>> Long lastValue = 0L
>> , start = 0L
>> , end = 0L;
>> public PathFilter(Long start, Long end) {
>> this.start = start;
>> this.end = end;
>> }
>> @SuppressWarnings("unchecked")
>> public Evaluation evaluate(Path path) {
>> List<Relationship> filteredRels = (List<Relationship>)
>> CollectionUtils.select(IteratorUtils.toList(path.relationships().iterator()),
>>
>> new PathFilter(start, end));
>> if (path.length() == filteredRels.size()) {
>> return Evaluation.INCLUDE_AND_CONTINUE;
>> }
>> return Evaluation.EXCLUDE_AND_PRUNE;
>> }
>> public boolean evaluate(Object arg) {
>> if (!(arg instanceof Relationship)) {
>> return false;
>> }
>> if (lastValue == 0L) {
>> lastValue = start;
>> }
>> Relationship rel = (Relationship) arg;
>> Long property = (Long) rel.getProperty("property");
>> if (evaluateDate(property, lastValue, end)) {
>> lastValue = property;
>> return true;
>> }
>> return false;
>> }
>> private boolean evaluateDate(Long value, Long start, Long end) {
>> return value >= start && value <= end;
>> }
>> }
>>
>> Another request:
>> exists already a construct that allows cypher to make an assessment of
>> this type?
>> Thanks to all
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Neo4j" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.