skip to Main Content

Suppose that I want all vertices and edges (and paths) to be listed in a single column, ordered by their type, is it a possibility?

The documentation does not say anything about that even though it does mention edge, path, vertex, map in orderability?

What could be a possible query to achieve this?

EDIT:
This is somewhat of an output I am looking for

Image

It clearly displays the orderability between Path, edge, and vertex, however, this only works because they are stored in the form of a property of different vertices.

Is it possible to query for all paths, vertices, edges like this in a single column?

2

Answers


  1. You can take the union of a list of all the vertices and edges. Add an extra column that tells if it is a vertex or an edge. Then it can be ordered using the extra column.

    Login or Signup to reply.
  2. To get the vertices, edge in a single column you can try something like:

    SELECT * FROM cypher('graph', $$
    MATCH (n)-[e]->(m)
    RETURN [n, e, m]
    $$) AS (result agtype);
    

    This will return a list consisting of start vertex, edge, end vertex that make a relationship

    In case you need a path, then the following query would work

    SELECT * FROM cypher('graph', $$
    MATCH p = (n)-[e]->(m)
    RETURN p        
    $$) AS (result agtype);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search