Q:

Neo4j, how to pagination nodes with all relations

I need read some data from neo4j for front-end visualizations. I need read 10 nodes at one time, and all the relations between them. I tried some queries, but none of them works.
match (p:Page{domain:"www.google.com"})-[r:LinkTo]-(:Page)
with p,r skip 10 limit 10
return collect(distinct p) as pages, collect(distinct r) as links;

this one would give me 10 nodes and 10 relations, but number of relations are more than 10 between those nodes.
Any help would be appreciated. 

A:

// 1) Collect pages:
match (P1:Page{domain:"www.google.com"})-[:LinkTo]-(P2:Page)
with P1, P2 limit 10
with collect(distinct P1) + collect(distinct P2) as tmp
unwind tmp as p
with collect(distinct p) as pages

// 2) Then get a Cartesian product:    
unwind pages as P1
  unwind pages as P2
  optional match (P1)-[r:LinkTo]-(P2)
RETURN pages, collect(distinct r) as links

If you need exact maximum 10 nodes:
 // 1) Collect pages:
MATCH (P1:Page{domain:"www.google.com"})-[:LinkTo]-(P2:Page)
WITH P1, P2 LIMIT 10
WITH collect(distinct P1) + collect(distinct P2) as CP
UNWIND CP  as P
WITH distinct P LIMIT 10
WITH collect(P) as pages

// 2) Then get a Cartesian product:    
unwind pages as P1
  unwind pages as P2
  optional match (P1)-[r:LinkTo]-(P2)
RETURN pages, collect(distinct r) as links

