Revisions
-
mneedham revised this gist
May 22, 2014 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,14 +23,12 @@ CREATE (:User {name:name}) [source,cypher] ---- MATCH (u:User) WHERE u.name =~ 'M.*' WITH collect(u) as users WITH users[..-1] AS c1, users[1..] as c2 UNWIND reduce(acc=[], x in range(0,length(c1) -1) | acc+ [ [c1[x], c2[x]] ]) AS pair WITH pair[0] AS p1, pair[1] AS p2 CREATE (p1)-[:OWNS]->(p2) ---- //graph -
mneedham revised this gist
May 21, 2014 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,12 +24,13 @@ CREATE (:User {name:name}) [source,cypher] ---- MATCH (u:User) WHERE u.name =~ 'M.*' WITH collect(u) as users UNWIND users AS u1 UNWIND users[1..] AS u2 create (u1)-[:knows]-> (u2) ---- //graph -
mneedham revised this gist
May 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ == How to create relatonships between elements in a collection :neo4j-version: 2.1.0 :author: Mark Needham :twitter: @markhneedham -
mneedham revised this gist
May 21, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,7 @@ == How to create relatonships between elements in a collection :neo4j-version: 2.1.0-RC1 :author: Mark Needham :twitter: @markhneedham This GraphGist answers a http://stackoverflow.com/questions/23779226/how-to-create-relatonship-between-elements-in-collection[Stackoverflow question]. -
mneedham revised this gist
May 21, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,8 @@ We want to create a social network, and have to connect some people. Let's do th [source,cypher] ---- UNWIND ["Amanda","Michael", "Max","Magnus","Mark","Peter","Andres"] AS name CREATE (:User {name:name}) ---- //graph -
jexp revised this gist
May 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ == How to create relatonships between elements in a collection This GraphGist answers a http://stackoverflow.com/questions/23779226/how-to-create-relatonship-between-elements-in-collection[Stackoverflow question]. -
jexp revised this gist
May 21, 2014 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ == How to create relatonship between elements in collection This GraphGist answers a http://stackoverflow.com/questions/23779226/how-to-create-relatonship-between-elements-in-collection[Stackoverflow question]. === Creating A Sample User Graph We want to create a social network, and have to connect some people. Let's do that in two steps. -
jexp revised this gist
May 21, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,9 @@ == Creating A Sample User Graph This GraphGist answers a http://stackoverflow.com/questions/23779226/how-to-create-relatonship-between-elements-in-collection[Stackoverflow question "How to create relatonship between elements in collection"]. We want to create a social network, and have to connect some people. Let's do that in two steps. === Create a few users [source,cypher] -
jexp created this gist
May 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ == Creating A Sample User Graph === Create a few users [source,cypher] ---- FOREACH (name in ["Amanda","Michael", "Max","Magnus","Mark","Peter","Andres"] | CREATE (:User {name:name})) ---- //graph === Connecting users starting with M [source,cypher] ---- MATCH (u:User) WHERE u.name =~ 'M.*' WITH collect(u) as users foreach ( i in range(1,length(users)-1) | foreach (u1 in [users[i-1]] | foreach ( u2 in [users[i]] | create (u1)-[:knows]-> (u2) )) ) ---- //graph