Hello,
I am trying to calculate the node embeddings for a graph containing variable-length relationships between nodes. However, when I try to create the graph with the following code,
MATCH (t)<-[ad:rel*]-(a)
WITH gds.graph.project('testGraph', t, a, {sourceNodeLabels:labels(a),targetNodeLabels:labels(t), relationshipType:type(ad) }, {undirectedRelationshipTypes: ['*']}) AS g
RETURN g.graphName AS graph, g.nodeCount AS nodes, g.relationshipCount AS rels
I am getting "Type mismatch: expected Relationship but was List". I tried using UNWIND and relationships() methods. Below is the code I tried
MATCH path = (t)<-[ad:rel*]-(a:Label)
WITH t, a, relationships(path) AS rels
WITH gds.graph.project('testGraph', t, a, {sourceNodeLabels:labels(a), targetNodeLabels:labels(t), relationshipType:type(rels[0])}, {undirectedRelationshipTypes: ['*']}) AS g
RETURN g.graphName AS graph, g.nodeCount AS nodes, g.relationshipCount AS rels
MATCH (t)<-[ad:rel*]-(a:labels)
UNWIND ad AS singleRel
WITH t, a, singleRel
WITH gds.graph.project('testGraph', t, a, {sourceNodeLabels:labels(a), targetNodeLabels:labels(t), relationshipType:type(singleRel)}, {undirectedRelationshipTypes: ['*']}) AS g
RETURN g.graphName AS graph, g.nodeCount AS nodes, g.relationshipCount AS rels
Using both approaches will result in a relationship between nodes that currently do not exist. Can you please suggest how to create the graph with variable-length relationships using cypher projection in the GDS library?
Thanks in advance.