Neo4j 求和路径中的节点值

Neo4j Summing node values in path

我有这种方法可以找到从起始节点开始的所有路径,并且return对于每条路径,具有每个节点中得分值总和的路径。

public List<PathScore> GetHighScorePath(string nodeName)
    {
        try
        {
            List<PathScore> result =
                this.client.Cypher.Match("p=(n)-[*]->(leaf)")
                .Where((LogEvent n) => n.Name == nodeName)
                .AndWhere("Not ((leaf)-->(n))")
                .ReturnDistinct(p => new PathScore
                {
                    Nodes = Return.As<IEnumerable<Node<LogEvent>>>("nodes(p)"),
                    Relationships = Return.As<IEnumerable<RelationshipInstance<Pivot>>>("rels(p)"),
                    pScore = Return.As<int>("REDUCE(total = 0, n IN nodes(p) | total + n.Score)")
                })
                .Results.ToList();
            return result;

        }}

这是我的路径结果class

public class PathScore
{
    public IEnumerable<Node<LogEvent>> Nodes { get; set; }
    public IEnumerable<RelationshipInstance<Pivot>> Relationships { get; set; }
    public int pScore;
}

但是我从 neo4j 收到这个错误消息

Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied.

我认为错误在于 return 分数作为 returned 对象的一部分的部分。这是导致错误的行:

pScore = Return.As<int>("REDUCE(total = 0, n IN nodes(p) | total + n.Score)")

好的,所以我遗漏了 get/set 访问器只是一个错误。

这是编辑后的版本

 public class PathScore
{
    public IEnumerable<Node<LogEvent>> Nodes { get; set; }
    public IEnumerable<RelationshipInstance<Pivot>> Relationships { get; set; }
    public int pScore { get; set; }
}