Open guangchen811 opened 9 months ago
Hello @guangchen811 and thank you for reaching out.
I just want to confirm that this feature does not exist currently, but we are happy to receive your request. The best that I can offer you is to manage the disambiguation yourself, by projecting your own key via the relationship projection.
To exemplify what I mean using your example, you could do the following projection:
MATCH (source)
OPTIONAL MATCH (source)-[r]->(target)
WITH gds.graph.project(
'graph_0',
source,
target,
{
sourceNodeLabels: labels(source),
targetNodeLabels: labels(target),
relationshipType: type(r),
relationshipProperties: {key: id(r)}
}
) AS g
RETURN g.graphName AS graph, g.nodeCount AS nodes, g.relationshipCount AS rels
Then your graph.sample
projection should also include these keys, allowing you to disambiguate them towards the original relationships.
I hope this helps in lieu of your actual request being supported! All the best Mats
Is your feature request related to a problem? Please describe. After running a random walk algorithm like
gds.graph.sample.rwr
, I want to get which relationships are visited. The following is an example to clarify what I want.(bob)-[:PAYS { amount: 3.0}]->(instrumentSeller), (bob)-[:PAYS { amount: 4.0}]->(instrumentSeller), (carol)-[:PAYS { amount: 5.0}]->(bob), (carol)-[:PAYS { amount: 6.0}]->(bob)
MATCH (source) OPTIONAL MATCH (source)-[r]->(target) WITH gds.graph.project( 'graph_0', source, target, { sourceNodeLabels: labels(source), targetNodeLabels: labels(target), relationshipType: type(r) } ) AS g RETURN g.graphName AS graph, g.nodeCount AS nodes, g.relationshipCount AS rels
// return: // graph nodes rels // "graph_0" 4 10
MATCH (start:Buyer {name: 'Alice'}) CALL gds.graph.sample.rwr('mySample', 'graph_0', { samplingRatio: 0.66, startNodes: [id(start)] }) YIELD nodeCount, relationshipCount RETURN nodeCount, relationshipCount // return: // nodeCount relationshipCount // 3 8