0

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?

5 Answers5

1

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);
Zainab Saad
  • 728
  • 1
  • 2
  • 8
0

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.

abhishek2046
  • 312
  • 1
  • 11
0

You can simply query for paths since a path contains vertices and edges between them. This can be achieved with the query below:

SELECT * FROM cypher('graphname', $$
MATCH p= (n1)-[r]->(n2)
RETURN p
$$) AS (outcome agtype);
Tito
  • 289
  • 8
0

You could query for the all vertices and edges by using this query.

SELECT * FROM cypher ('orderability_graph', $$
MATCH p = ()-[]-()
RETURN p
$$) AS (sorted agtype);

This query will display a path consisting of all vertices and edges.

0

you can use this query to display all available edges and vertices

Select * from cypher ('orderability_graph',$$ MATCH graph=(node1)-[rel]-(node2) Return graph $$) as (sorted agtype);