| purpose |
Cypher query |
comment |
| list all distinct node labels
# |
MATCH (n) RETURN DISTINCT labels(n) |
what is the schema for nodes? |
| list all distinct edge labels
# |
MATCH (a)-[r]->(b) RETURN DISTINCT type(r) |
what is the schema for edges? |
| count all nodes
# |
MATCH () RETURN count(*) AS totalNodes |
|
| count all edges
# |
MATCH ()-[r]->() RETURN count(r) |
|
| list the node count for each label
#
|
MATCH (n) RETURN DISTINCT labels(n), count(*) |
how many nodes of each type? |
| list all nodes
# |
MATCH (n) RETURN n |
|
| list all edges
# |
MATCH (n)-[r]->(m) RETURN r |
|
| list all nodes and edges
# |
MATCH (n)-[r]->(m) RETURN n,r,m |
|
| step not connected to derivation
# |
MATCH (s:step) WHERE NOT (:derivation)-[:HAS_STEP]->(s) RETURN s |
find all :step nodes that are not connected to a :derivation node via a HAS_STEP relationship |
| step with no expression
# |
MATCH (s:step) WHERE NOT (s)-[:HAS_INPUT|HAS_OUTPUT]->(:expression) RETURN s |
find all step nodes that are not connected to an expression via HAS_INPUT or HAS_OUTPUT relationship |
| step missing inference rule
# |
MATCH (s:step) WHERE NOT (s)-[:HAS_INFERENCE_RULE]->(:inference_rule) RETURN s |
find all step nodes that are not connected to an inference_rule via HAS_INFERENCE_RULE relationship |
| step not connected to other steps via expression
# |
MATCH (s:step) WHERE NOT EXISTS { MATCH (s)-[:HAS_INPUT|HAS_OUTPUT]->(e:expression)<-[:HAS_INPUT|HAS_OUTPUT]-(other:step) WHERE s <> other } RETURN s |
find :step nodes that are not connected to any other :step nodes through an intermediate :expression. |
|
all distinct node labels and the unique property keys used within each label.
# |
MATCH (n) UNWIND labels(n) AS label UNWIND keys(n) AS key RETURN DISTINCT label, collect(DISTINCT key) AS properties ORDER BY label |
|
|
all distinct relationship types and the unique property keys used for each type.
# |
MATCH ()-[r]-() WITH type(r) AS relationshipType, keys(r) AS keys UNWIND keys AS key RETURN DISTINCT relationshipType, collect(DISTINCT key) AS properties ORDER BY relationshipType |
|
|
all distinct relationship types and the unique property keys used for each type, including empty properties.
# |
MATCH ()-[r]->() WITH type(r) AS relationshipType, keys(r) AS keys UNWIND (CASE WHEN size(keys) = 0 THEN [null] ELSE keys END) AS key RETURN relationshipType, collect(DISTINCT key) AS properties ORDER BY relationshipType |
|
| list derivations
# |
MATCH (n:derivation) RETURN n |
See also table of derivations |
| list inference rules
# |
MATCH (n:inference_rule) RETURN n |
See also table of inference rules |
| list steps
# |
MATCH (n:step) RETURN n |
|
| list expressions
# |
MATCH (n:expression) RETURN n |
See also table of expressions |
| list scalar symbols
# |
MATCH (n:scalar) RETURN n |
See also table of scalar symbols |
| list vector symbols
# |
MATCH (n:vector) RETURN n |
See also table of vector symbols |
| list matrix symbols
# |
MATCH (n:matrix) RETURN n |
See also table of matrix symbols |
| list operations
# |
MATCH (n:operation) RETURN n |
See also table of operations |
| list relations
# |
MATCH (n:relation) RETURN n |
See also table of relations |
| list constant values with units
# |
MATCH (n:value_with_units) RETURN n |
See also table of scalar symbols |
| list steps for a derivation
# |
MATCH (n:step), (m:derivation) WHERE m.id='000005' RETURN n |
See also review_derivation 000005 |
| list every node that a step connects to
# |
MATCH (s:step)-[r]->(e) WHERE s.id='1029890' RETURN e |
all input expressions, feeds, and output expressions |
| all named expressions
# |
MATCH (e:expression) WHERE e.name_latex <> "" RETURN e |
|
| list pairs of nodes with edge HAS_VALUE# |
MATCH (a)-[:HAS_VALUE]->(b) RETURN a, b |
See also list all distinct edge labels. |
| list inference rule used in a specific step
# |
MATCH (i:inference_rule), (s:step) WHERE s.id='1029890' RETURN i |
|
| list expressions connected to a specific inference rule
# |
MATCH (n:expression), (m:inference_rule) WHERE m.id='111355' RETURN n |
|
| list symbol dicts connected to a specific expression
# |
MATCH (e:expression {id: '111355'})-[:HAS_SYMBOL]->(s:symbol) RETURN properties(s) AS props |
|
| show properties for a specific derivation
# |
MATCH (d:derivation) WHERE d.id = '000005' RETURN d
or
MATCH (n:derivation {id:'000005'}) RETURN n |
|
| show properties for a specific expression
# |
MATCH (n:expression) WHERE n.id='0203024440' RETURN n |
|
[ILL-POSED] list expressions that have a name
# |
[ILL-POSED]
MATCH (n:expression) WHERE n.name_latex <> '' RETURN n |
query assumes the name_latex always exists on the nodes being considered. If the property might be missing, n.name_latex would be null, and null <> '' would evaluate to true. |
| list expressions that have a name
# |
MATCH (n:expression) WHERE exists(n.name_latex) AND n.name_latex <> '' RETURN n |
check for existence of name_latex |
| expression nodes connected to two or more unique derivation nodes
# |
MATCH (d:derivation)-[:HAS_STEP]->(s:step)-[:HAS_INPUT|HAS_OUTPUT]->(e:expression) WITH e, count(DISTINCT d) AS derivationCount WHERE derivationCount >= 2 RETURN e |
|
| named expressions connected to two or more derivations
# |
MATCH (d:derivation)-[:HAS_STEP]->(s:step)-[:HAS_INPUT|HAS_OUTPUT]->(e:expression) WHERE e.name_latex IS NOT NULL AND e.name_latex <> "" WITH e, count(DISTINCT d) AS derivationCount WHERE derivationCount >= 2 RETURN e |
|
| an inference rule is in which derivations?
# |
MATCH (d:derivation),(s:step),(i:inference_rule) WHERE i.id='111355' RETURN DISTINCT d
|
|
| regex search for text in a node's property
# |
MATCH (m:scalar) WHERE (any(prop in keys(m) WHERE m[prop] =~ '.*ddd.*')) RETURN m
|
replace 'ddd' with your desired text |
| shortest path length between two inference rules
# |
MATCH p = shortestPath((n:inference_rule)-[*..]-(m:inference_rule)) WHERE n.id = '8208125' AND m.id = '7208176' RETURN length(p)
|
replace ID values with your desired nodes |
| shortest path between two inference rules
# |
MATCH p = shortestPath((n:inference_rule)-[*..]-(m:inference_rule)) WHERE n.id = '111355' AND m.id = '7208176' RETURN p
|
replace ID values with your desired nodes |
| longest shortest path, aka diameter
# |
MATCH (n), (m) WHERE id(n) < id(m) MATCH p = shortestPath((n)-[*]-(m)) RETURN p, length(p) AS distance ORDER BY distance DESC LIMIT 1 |
|