3

I create a relationship as the following in Neo4php

$src->relateTo($dst, 'FRIENDS')
    ->setProperty('duration', '5')
    ->save();

I want the relationship be undirected not directed. If I am not wrong we can do this in Cypher

create n-[:FRIENDS]-m

vs

create n-[:FRIENDS]->m

How about in Neo4jphp? Can we set "relateTo" to a bi-directional relationship?

user1848018
  • 1,086
  • 1
  • 14
  • 33

1 Answers1

8

Neo4j does not support undirected relationships. What you are asking for is impossible. Why do you want undirected relationships? If the direction doesn't make sense for your domain, just pick a direction arbitrarily and ignore it when traversing or querying.

Josh Adell
  • 1,555
  • 8
  • 12
  • We can do this in cypher, create n-[:likes]-m vs create n-[:likes]->m, you mean the above two commands are the same? – user1848018 Jul 09 '13 at 19:40
  • I thought n-[:likes]-m meant "n-[:likes]->m OR n<-[:likes]-m". At least, that's how I've used it, when I don't care what the direction of the relationship is. – Josh Adell Jul 18 '13 at 20:27