skip to Main Content

Apache AGE gives the following way of obtaining path from one vertex to the other through variable number of intermediary nodes.

(u)-[*3..5]->(v)

I tried the following query in Apache AGE and it indeed does give the desired result.

test=# SELECT * from cypher('cities', $$
MATCH p = (d:CITY {name:"Delhi"})-[:WAY_TO*..2]-(r:TOWN {name:"Rishikesh"})
RETURN relationships(p)
$$) as (a agtype);
                                                                                                                                              a                                                            
                                                                                  
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------
 [{"id": 1125899906842630, "label": "WAY_TO", "end_id": 844424930131980, "start_id": 844424930131977, "properties": {"distance": 2100}}::edge, {"id": 1125899906842640, "label": "WAY_TO", "end_id": 140737
4883553282, "start_id": 844424930131980, "properties": {"distance": 2300}}::edge]
 [{"id": 1125899906842629, "label": "WAY_TO", "end_id": 1407374883553282, "start_id": 844424930131977, "properties": {"distance": 230}}::edge]
 [{"id": 1125899906842628, "label": "WAY_TO", "end_id": 844424930131979, "start_id": 844424930131977, "properties": {"distance": 1500}}::edge, {"id": 1125899906842639, "label": "WAY_TO", "end_id": 140737
4883553282, "start_id": 844424930131979, "properties": {"distance": 1700}}::edge]
 [{"id": 1125899906842627, "label": "WAY_TO", "end_id": 1407374883553281, "start_id": 844424930131977, "properties": {"distance": 40}}::edge, {"id": 1125899906842637, "label": "WAY_TO", "end_id": 1407374
883553282, "start_id": 1407374883553281, "properties": {"distance": 211}}::edge]
 [{"id": 1125899906842626, "label": "WAY_TO", "end_id": 844424930131978, "start_id": 844424930131977, "properties": {"distance": 1400}}::edge, {"id": 1125899906842634, "label": "WAY_TO", "end_id": 140737
4883553282, "start_id": 844424930131978, "properties": {"distance": 1700}}::edge]
(5 rows)

However, the same query in AGE viewer does not yield any output.
enter image description here

I realize it may be because no agtype variables were declared for the intermediary nodes, however, I wanted to know if there is a workaround to obtain the desired result.

2

Answers


  1. Functions relationships() provided by apache-age returns a list containing all the relationships/edges in a path.

    So you are using relationships() function in the return statement:

    RETURN relationships(p)

    So in this case you will get a list containing all the edges in the path p.

    This is just like getting the complete details of all edges, there id, start point, end point label etc. but there is actually no use of drawing the edges only. so they are not drawn in age-viewer, but you can simply view the list in the Table section rather than graph section.

    To find further on the relationship() function you can refer to the docs here

    Login or Signup to reply.
  2. It is not possible to use relationships(p) to solely examine the edges of a graph on age-viewer since a graph must contain at least one vertex to be considered a graph. A graph is defined as a collection of vertices and the edges that connect them, and without vertices, there cannot be any edges to examine.

    Try using this query instead:

    SELECT * from cypher('cities', $$
        MATCH p = (d:CITY {name:"Delhi"})-[:WAY_TO*..2]-(r:TOWN {name:"Rishikesh"})
        RETURN p
    $$) as (a agtype);
                   
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search