在Neo4j中显示关系

时间:2019-05-20 15:58:45

标签: neo4j relationship

我写了一个CQL,现在以表格格式获取结果,现在我想以图形方式显示它。

这是CQL中的代码:

match (tc:TeamCoaches)-[:BELONGS_TO]->(t:Teams)
with t.TeamName as TeamNames, 
count(distinct tc.CoachName) as no_of_coach,
collect (tc.CoachName) as Coachnames
where no_of_coach>= 2
return  TeamNames, no_of_coach,Coachnames

Actual Results:

TeamNames               no_of_coach           Coachnames
A                            2                 [P,Q]
B                            3                 [X,Y,Z]

预期结果:应采用图形形式。 示例:

       (P)------------->(A)<---------------(Q)
            BELONGS_TO         BELONGS_TO


             BELONGS_TO        BELONGS_TO
       (X)------------->(B)<--------------->(Y)
                         ^
                         |
                         |BELONGS_TO
                         |
                        (Z)

1 个答案:

答案 0 :(得分:1)

您需要返回nodes而不是其属性(此处是返回名称),以图形形式显示。

您可以修改查询以图形形式显示为:

MATCH (tc:TeamCoaches)-[:BELONGS_TO]->(t:Teams)
WITH t, count(distinct tc) as no_of_coach
WHERE no_of_coach>= 2
MATCH P=(tc:TeamCoaches)-[:BELONGS_TO]->(t)
RETURN  P