0
votes

We have stored 4 different sub graph in neo4j. All nodes and relationships have a property called "species" to indicate which sub graph the node or relationship is in. That means all nodes and relationships in sub graph "rice" have a property {"species":"rice"},and we also have other sub graphs: "maize","tair",...

My difficulty is to find all the sub graph label ("rice","maize","tair",...) using py2neo. I want to tell people have many species we have in the database.

1

1 Answers

1
votes

The respective Cypher query is:

MATCH (n:Mylabel)
RETURN DISTINCT n.species

With py2neo you can run this query as follows:

from py2neo import Graph

graph = Graph()

q = "MATCH (n:Mylabel) RETURN DISTINCT n.species"
result = graph.cypher.execute(q)

for row in result:
    # collect your result
    print(row[0])