Created
March 10, 2016 18:14
-
-
Save Dalamar42/1ec93cd74b01c145e7bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROFILE | |
MATCH (n:Label{ id:1} ) | |
WITH n AS entry_node, collect(n) AS nodes_found_blue, collect(n) AS nodes_to_visit | |
UNWIND nodes_to_visit AS n | |
MATCH (n)-[:REL]-(target_node) | |
WHERE target_node = entry_node OR NOT target_node IN nodes_found_blue | |
WITH entry_node, nodes_found_blue + collect(DISTINCT target_node) AS nodes_found_green, | |
collect(DISTINCT target_node) AS nodes_to_visit | |
UNWIND nodes_to_visit AS n | |
MATCH (n)-[:REL]-(target_node) | |
WHERE target_node = entry_node OR NOT target_node IN nodes_found_green | |
WITH entry_node, nodes_found_green + collect(DISTINCT target_node) AS nodes_found_blue, | |
collect(DISTINCT target_node) AS nodes_to_visit | |
UNWIND nodes_found_blue AS n | |
RETURN DISTINCT n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment