0
votes

Hello I make a Graph Algorithm Neo4J request in Cypher of the following kind, which first finds the nodes and then the relations between them:

CALL algo.pageRank.stream('MATCH (u:User{uid:"0ee14110-426a-11e8-9d67-e79789c69fd7"}), 
(ctx:Context{name:"news180417"}), (u)<-[:BY]-(c:Concept)-[:AT]->(ctx) 
RETURN DISTINCT id(c) as id', 
'CALL apoc.index.relationships("TO","user:0ee14110-426a-11e8-9d67-e79789c69fd7") 
YIELD rel, start, end WITH DISTINCT rel, start, end MATCH (ctx:Context) 
WHERE rel.context = ctx.uid AND (ctx.name="news180417" ) 
RETURN DISTINCT id(start) AS source, id(end) AS target', 
{graph:'cypher', iterations:5});

Which works fine. However, when I try to return c.uid instead of its Neo4J id() the Graph Algorithms don't accept it.

Does it mean I can only operate using Neo4J ids in Graph Algorithms?

1
What is the error given by Graph Algorithms that indicates that it does not accept c.uid? - Rebecca Nelson
@RebeccaNelson that id Should be integer - Aerodynamika
It sounds like the library will not allow you to call a MATCH pattern that returns a non-int. - Rebecca Nelson
Exactly. So that was what the question was about. - Aerodynamika
Ah, sorry, it looks like I misinterpreted you. If the question is that "given this library says I can't return a String, can I return a string?" the answer is of course, "no, that is not possible". Are you looking for an alternate invocation or library that can accept label as a string value for PageRank? - Rebecca Nelson

1 Answers

4
votes

When you use Cypher projection with the Graph Algorithms procedures, you pass 2 Cypher statements (and a config map).

The first Cypher statement must return an id variable whose value is the native ID of a node.

The second Cypher statement must return source and target variables whose values are also node IDs.

So, yes, your Cypher statements must always return neo4j native IDs.