cancel
Showing results for 
Search instead for 
Did you mean: 

Need a little help in creating graph for GDS analysis

andy_hegedus
Graph Voyager

Hi,
I am struggling a bit to figure out how to create a named graph for GDS analysis.
My objective: I have a central point of interest (central blue node), a patent in this case. There are other patents which have a relationship, cited by an examiner in this case. Now patents have technology classifications, cpc codes, and the cpc codes are part of a tree structure hierarchy.
What I am interested in answering: For the cpc nodes attached to my target patent what is the shortest route from those cpc codes to the cpc codes of the cited patents. It seems like I would like to do a version of shortest path but only traversing the :Classified_as and :Reports_to relationships.
Question 1. How would I write the gds.graph.create to capture this graph. The examples in the documentation are relatively simplistic.
Question 2. How would I wind array of nodes to get all shortest paths?
Question 3. In cypher I am getting a warning that the where clause I am using is depreciated, what would the alternative suggested form be?

Match p=(x:patent{num:7122415})-[:Classified_as]->(a:cpc)-[:Reports_to*]-(:cpc)<-[:Classified_as]-(b:patent) 
where (x)-[:Cites{who:'examiner'}]->(b)
return p

Thanks in advance
Andy

2 REPLIES 2

The cypher warning -> WHERE exists { pattern }

You could load your whole graph into GDS, and then use the shortest-path procedures there.

But it might be overkill perhaps something like APOC Path expanders are enough to specify which labels to include in a shortest path search?

Or just regular cypher with:

Match p=shortestPath( (x:patent{num:7122415})-[:Classified_as|Reports_to*]-(b:patent) )
where (x)-[:Cites{who:'examiner'}]->(b)
return p

andy_hegedus
Graph Voyager

Hi,

Thanks for the tips, but still could use some assistance.

I have created a gds graph with

CALL gds.graph.create('test',['patent','cpc'],['Classified_as','Reports_to'])

And I am using a simplified test case.
based on this cypher query

Match p=(source:patent{num:7122415})-[:Classified_as]-(cpc)-[:Reports_to*..]-(:cpc)-[:Classified_as]-(target:patent{num:6376888})
Return p

Which gives this result

And now I would like to find the shortest path between the blue nodes that traverses only through the green nodes. The relation between blue and green is Classified_as and among green is Reports_to.
I have tried this query:

Match (source:patent{num:7122415}),(target:patent{num:6376888})

CALL gds.shortestPath.dijkstra.stream('test',{sourceNode:source,targetNode:target})

YIELD sourceNode, targetNode, nodeIds, path

RETURN sourceNode, targetNode, nodeIds, path

And it yields no results. Advice. It should be noted that the relationship are directed. Do I need to remove the direction in GDS graph?
If so what is the correct syntax? I have tried this

CALL gds.graph.create('test',['patent','cpc'],{'Classified_as':{orientation:'UNDIRECTED'}},{'Reports_to':{orientation:'UNDIRECTED'}})

but it returns an error at the relationship definition.
Andy