Created
March 5, 2021 10:15
-
-
Save davidrapin/eb69215c23495c4984a507fc5aa3ac4e to your computer and use it in GitHub Desktop.
Generate edge types (Neo4j Cypher)
This file contains hidden or 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
// edgeCount: the number of edges with a unique edge-type to generate | |
// sourceNodeId: ID of the node to be used as source for all generated edges | |
// targetNodeId: ID of the node to be used as target for all generated edges | |
// prefix: the edge-type prefix to use for generated edge-types | |
WITH 100 as edgeCount, 1 as sourceNodeId, 2 as targetNodeId, "edge_type_prefix_" as prefix | |
MATCH (a), (b) WHERE id(a) = sourceNodeId and id(b) = targetNodeId | |
WITH range(1, edgeCount) as xx, a, b | |
UNWIND xx AS x | |
CALL apoc.create.relationship(a, prefix + toString(x), {property: x}, b) YIELD rel | |
RETURN a, b, rel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment