Neo4JClient: How to view the relationship (Direct reportees)?

 ̄綄美尐妖づ 提交于 2019-12-13 22:25:02

问题


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?

Update

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;

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?


回答1:


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

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


来源:https://stackoverflow.com/questions/35252922/neo4jclient-how-to-view-the-relationship-direct-reportees

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!