Closed maorzsh closed 1 year ago
@RiskyMaor You are right that a Cypher-projected graph is always directed. We do not inspect the provided queries (as these may be arbitrarily complex) but we only consume the result of the queries and build a graph based off that. As such we cannot guarantee that the graph is or is not UNDIRECTED
but we simply take the relationships we get as standard directed relationships.
You are also right that we claim otherwise in the documentation through
The cypher projection can achieve the same feature by adjusting the MATCH clause of the relationship query.
Indeed, it is not quite the same because the GDS algorithm does not have access to the metadata that the projected graph is UNDIRECTED
(the metadata says it's NATURAL, like all Cypher-projected graphs). So any and all algos that react to this metadata will not behave the same way.
It is still accurate that by removing the direction from a (simple) Cypher query will achieve the effect of UNDIRECTED
by way of projecting twice as many relationships.
I will take this to the team and we'll make some kind of correction here to make this difference more clear.
Thanks a lot for raising this issue!
All the best Mats
Thanks for the prompted and detailed response!
With 2.3 we introduced a undirectedRelationshipTypes
parameter which allows you to load undirected graphs (https://neo4j.com/docs/graph-data-science/current/management-ops/projections/graph-project-cypher-aggregation/#_undirected_relationships).
However, this is only supported for the newer Cypher Aggregation and Native Projection.
Alternatively, you can still use the old Cypher projection and convert the relationships to undirected (see https://neo4j.com/docs/graph-data-science/current/graph-catalog-relationship-ops/#catalog-graph-relationship-to-undirected-example).
Background It seems that a cypher-projected undirected graph is treated as if it was directed. I'm new to Neo4j so I can't tell for sure if it's a bug or I'm doing something wrong.
Environment
Reproduction
6
foro1
node and0
for the rest. The native projection seems to be ok:However, the cypher projection returns a different result, more specifically, it seems it treats the edges as directed edges, e.g. o2->o1->o3 and o3->o1->o2 are counted as two distinct paths even though I asked for an undirected graph.