0
MATCH (a:Person)-[l:workWith]-(b:Person) RETURN a, l, b

If I execute a query and it returns three values (start node, edge, and end node), how can I modify the query to retrieve only the information about the edge

cybersam
  • 63,203
  • 6
  • 53
  • 76
M Jin
  • 11
  • 1

4 Answers4

3

You can just modify it to:

MATCH (a:Person)-[l:workWith]-(b:Person) RETURN l

to retrieve only the information about the edge.

Since you are only trying to print the edges so no graph will show up.

You can choose the Table from the option given viewing graph or Table for this specific query in age-viewer GUI.

enter image description here

Kamlesh Kumar
  • 351
  • 1
  • 7
0

The return statement at the end of your query indicates what needs to be returned based on the labels following RETURN. The 'a' and 'b' labels in your query are for two individual vertices. The 'l' label is an edge label. Change your return statement to RETURN l should work.

marodin
  • 41
  • 2
0

In your query MATCH (a:Person)-[l:workWith]-(b:Person) RETURN a, l, b .You are returning a , l and b.

Here,

a is your start node.

b is also your end node.

and l is your edge workWith.

As you are returning a , b and l . So you are getting start node, edge and end node. If you return only l you will get only the information of edge.

For this your query will be modified as,

MATCH (a:Person)-[l:workWith]-(b:Person) RETURN l

0

Return only the edges instead of all nodes. Additionally, you can avoid using variables for nodes that won't be processed to optimize the query.

 MATCH (:Person)-[e:workWith]-(:Person) RETURN e
Mohayu Din
  • 433
  • 9