cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Best way to represent bidirectional relationships

halloleo
Node Link

Hi there

I'm just starting out to do a bit more with neo4j and I try to represent a truly bi-directional realtionship.

I know neo4j cannot store un-directional relationships ((a)--(b)), which would be an option. And I didn't manage to create bidirectional links ((a)<-->(b)) either in neo4j. (Maybe I did something wrong?)

So the next best option I though of is creating for every real bidirectional relationship two uni-directional relationships:

(a)-->(b)
(a)<--(b)

But this meant I have double as many relationships shown in the graph then really exist!

Also, just defining uni-directional links and using un-directional queries doesn't cut it either, because we use Neo4j Browser as visualisation frontend and it always shows the direction of the relationships.

So I'm a bit at a loss. What to do?

2 REPLIES 2

I don't think is currently possible with Neo4j Desktop / Browser.

You should do something like this to remove directions with pure CSS,

.relationship .outline {
  d:  path('M 25 0.5 L 37.9056 0.5 L 37.9056 -0.5 L 25 -0.5 Z M 59.4681 0.5 L 72.3737 0.5 L 72.3737 -0.5 L 59.4681 -0.5 Z') !important
}

But, to style something in Neo4j Browser you could use the :style statement,
as explained here,
but this is a pseudo-css, definitely not as complete as real css.

I would suggest you, if direction is important, to choose another viz tool, for example one of these (except Browser or Bloom)

Thanks @giuseppe.villani!

That's a good aproach: Keeping the links in the database unidirectional, but visualise them bi- or undirectional.

Might try neovis.js or Cytoscape...