2013-05-16 28 views

回答

0

這是我最終使用的評估者,其中IS_MEMBER是問題中描述的關係M.

public Evaluation evaluate(final Path path) { 
    if (path.length() == 0) { 
     return Evaluation.EXCLUDE_AND_CONTINUE; 
    } 
    boolean isOutgoingIS_MEMBER = (
     path.lastRelationship().getEndNode() == 
     path.endNode() && 
     (path.lastRelationship() 
    .isType(ReqsDb.RelTypes.IS_MEMBER))); 
    boolean isRelTypeUnique = true; 
    Iterator<Relationship> i = 
     path.reverseRelationships().iterator(); 
    i.next(); 
    while (i.hasNext()) { 
     if (i.next().isType(path.lastRelationship() 
       .getType())) { 
      isRelTypeUnique = false; 
      break; 
     } 
    } 
    boolean included = isOutgoingIS_MEMBER || isRelTypeUnique; 
    boolean continued = included; 
    return Evaluation.of(included, continued); 
} 
0

您可以使用PathExpander和可選的(用於執行)BranchState來保持每個分支在哪裏a.t.m的狀態。而不是在每次評估中查看路徑