Neo4j总结路径中的节点值
问题描述:
我有这种方法来查找所有来自起始节点的路径,并且为每个路径返回每个节点中Score值总和的路径。Neo4j总结路径中的节点值
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;
}}
这是我的路结果类
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.
我认为错误在于其中i返回分数作为部分的部分返回的对象。这是导致该错误的行:
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; }
}
确定愚蠢的我。我遗漏了我的pScore属性的获取设置访问方法 – Koh
那么这是否意味着它*现在正在工作? –
是的。这实际上是我的一个愚蠢的错误。将发布一个答案为此关闭此 – Koh