cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

fail to project graph with cypher

cat971216
Node Link

Hi,

I am a beginner and I am trying to use GDS to project my graph. I try to build a query like the tutorial  https://neo4j.com/docs/graph-data-science/current/graph-project-cypher/#_multi_graph shows but failed. May I know why my code did not work?

My query is 

CALL gds.graph.project.cypher(

    'centrality',
    'MATCH (n:AscdcProvidedCHO) RETURN id(n) AS id',
    'MATCH (n:AscdcProvidedCHO)-[r:subject|keywords{weight}]->(m) WHERE NOT m.uri = "http://dbpedia.org/resource/Insect" RETURN id(n) AS source, id(m) AS target, type(r) AS type'
)

The error message is:

Failed to invoke procedure `gds.graph.project.cypher`: Caused by: org.neo4j.exceptions.SyntaxException: Parameter maps cannot be used in MATCH patterns (use a literal map instead, eg. "{id: {param}.id}") (line 1, column 55 (offset: 54))
"EXPLAIN MATCH (n:AscdcProvidedCHO)-[r:subject|keywords{weight}]->(m) WHERE NOT m.uri = "http://dbpedia.org/resource/Insect" RETURN id(n) AS source, id(m) AS target, type(r) AS type"

 

By the way, I am projecting the graph to use algorithms such as centrality and similarity algorithms. I am wondering if I can delete some nodes in the projected graph without changing the original database? The code from the tutorial seems only copy the original graph, but I want to project only part of it, and even make further changes after I get results of centrality and similarity. Can I do that with a projected graph? 

Many thanks! 

1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

The one thing I see in error is that you did not provide a value for the 'weight' key in the relationship's properties map:  '[r:subject|keywords{weight}]'.  You need to add a value, such as: '[r:subject|keywords{weight:100}]'

View solution in original post

2 REPLIES 2

glilienfield
Ninja
Ninja

The one thing I see in error is that you did not provide a value for the 'weight' key in the relationship's properties map:  '[r:subject|keywords{weight}]'.  You need to add a value, such as: '[r:subject|keywords{weight:100}]'

Hi, Thank you for your suggestions, it works!

I also got error message like this:

Failed to invoke procedure `gds.graph.project.cypher`: Caused by: java.lang.IllegalArgumentException: Failed to load a relationship because its target-node with id 6761 is not part of the node query or projection. To ignore the relationship, set the configuration parameter `validateRelationships` to false.

  May I ask what it means that the node is not part of the query or projection? I am trying very simple projection:

CALL gds.graph.project.cypher(
    'project1',
    'MATCH (n:AscdcProvidedCHO) RETURN id(n) AS id',
    'MATCH (n:AscdcProvidedCHO)-[r:subject]->(m) RETURN id(n) AS source, id(m) AS target'
)