Skip to content

Instantly share code, notes, and snippets.

View mneedham's full-sized avatar

Mark Needham mneedham

View GitHub Profile

Learning dem graph gists

Awesome

Something something, graph gist

neo4j-meetup.core> (take 1 (map (fn [x] (println (str "printing..." x))) (range)))
(printing...0
printing...1
printing...2
printing...3
printing...4
printing...5
printing...6
printing...7
printing...8
(defn offsets [perpage]
(map #(* perpage %) (range)))
(defn events
[{perpage :perpage offset :offset orderby :orderby}]
(->> (client/get
(str "https://api.meetup.com/2/events?page=" perpage
"&offset=" offset
"&orderby=" orderby
"&status=upcoming,past&"
MATCH (meetup)-[:INITIALLY_RSVPD]->(rsvp1 {response: "yes"})-[:NEXT]->(rsvp2 {response: "no"})-[:TO]->(event)
MATCH (event)-[:HAPPENED_ON]->(ed1)<-[:HAS_DAY]-(em1)<-[:HAS_MONTH]-(ey1)
MATCH (rsvp1)-[:HAPPENED_ON]->(d1)<-[:HAS_DAY]-(m1)<-[:HAS_MONTH]-(y1)
MATCH (rsvp2)-[:HAPPENED_ON]->(d2)<-[:HAS_DAY]-(m2)<-[:HAS_MONTH]-(y2)
MATCH path = (d2)<-[:NEXT*]-(d1)
RETURN meetup.name,
event.name,
ed1.day + "/" + em1.month + "/" + ey1.year AS eventDate,
d1.day + "/" + m1.month + "/" + y1.year AS initialYes,
d2.day + "/" + m2.month + "/" + y2.year AS changedToNo,
= Rounding a float value to decimal places
:neo4j-version: 2.1.0-RC1
:author: Mark Needham
:twitter: @markhneedham
Every now and then I find myself dealing with float values such as the following:
[source,cypher]
----
RETURN toFloat("12.336666") AS value

How to create relatonships between elements in a collection

This GraphGist answers a 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.

library(Rneo4j)
library(ggplot2)
graph = startGraph("http://localhost:7474/db/data/")
query = "MATCH (group1:Group), (group2:Group)
WHERE group1 <> group2
OPTIONAL MATCH path = (group1)<-[:MEMBER_OF]-()-[:MEMBER_OF]->(group2)
WITH group1, group2, COLLECT(path) AS paths

Modelling time-varying financial exposures in Neo4j

Answer to this Stackoverflow Question

Question

How would one model this kind of data in Neo4j?:

> HOLDINGS
   Portfolio                         Holding    Instrument       Date BALANCE.USD

The World Cup Graph

The football World Cup is just under a week away so I thought we deserved a World Cup graph for the occasion. It’s still a work in progress but here’s what I’ve got so far.

The World Cup Graph

Initial Data Setup