O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Linking of a collection of nodes

Among the features that apply to a collection of nodes, there is linking. Calling a single procedure will make it possible to create ONE (same) relation between all the nodes of a collection. This example creates the relation EARTHBRO_OF between the nodes, as follows:

MATCH (p:Person)WITH collect(p) AS personsCALL apoc.nodes.link(persons,'EARTHBRO_OF')RETURN length(persons)

If we want to check whether there is only one EARTHBRO_OF, a Cypher query can be as follows:

MATCH (p:Person)-[r:EARTHBRO_OF]->(m:Person)RETURN p,count(r)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required