Neo4JClient:如何查看关系(直接报告者)? [英] Neo4JClient: How to view the relationship (Direct reportees)?
问题描述
我有一个使用 Neo4JClient:如何创建关系的关系创建示例? .如何看待这种关系?我的意思是,如果我想查找直接连接到"A"的节点数,该怎么做?
I have an example of creating relationship using Neo4JClient: How to create relationships?. How to view the relationship? I mean if I want to find how many nodes are directly connected to "A", how to do that?
在@manonthemat的帮助下,我将密码转换为C#
After a little help from @manonthemat, I converted the cypher in C#
var record = client.Cypher
.Match("(A)-[r]->()")
.Return((A, r) => new
{
User = A.As<ExampleNode>(),
NumberOfFriends = r.Count()
}).Results;
尽管我能够获得A的直接计数为4,但我也想获得这些名称,例如B,C,D,E.怎么做?
Though I am able to get the direct count say 4 for A, I also want to get the names of those e.g. B,C,D,E. How to do so?
推荐答案
我理解您的问题是如何确定连接到A的节点?"
I understand you question to be "How do I determine the nodes which are connected to A?"
如果只需要节点,则密码查询应如下所示:
If you only want the nodes, the cypher query should look something like this:
Match A-[r:*]-(X)
Return distinct X
如果您还想要这种关系,请尝试以下操作:
If you also want the relationships try this:
Match A-[r:*]-(X)
Return r, distinct X
有时候,您可能希望将搜索范围限制为仅某种类型的关系,例如"KNOWS".在这种情况下,请尝试以下操作:
Sometimes you may want to limit you search to only a certain kind of relationship, like "KNOWS". In which case try this:
Match A-[r:KNOWS*]-(X)
Return r, distinct X
这篇关于Neo4JClient:如何查看关系(直接报告者)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!