Skip to content

Instantly share code, notes, and snippets.

@luanne
luanne / NodeNotFoundInExpectedIndexWithConstraint.java
Created February 3, 2015 16:32
When a node is created by the batch inserter with a set of labels (of which one has a unique constraint defined on it), and then the labels are replaced with another set of labels in a particular order, the consistency checker produces "This node was not found in the expected index". Post this, the node cannot be retrieved by label MobileUser an…
package com.graphaware;
import com.rancard.domain.Labels;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.schema.ConstraintCreator;
import org.neo4j.unsafe.batchinsert.BatchInserter;
import org.neo4j.unsafe.batchinsert.BatchInserters;
import java.util.*;
@luanne
luanne / NodeNotFoundInExpectedIndex.java
Last active August 29, 2015 14:14
When a node is created with multiple labels and the order of labels supplied is such that a new label is first, and an existing label is next, where the existing label has a unique constraint defined on it, the constraint checker produces "This node was not found in the expected index"
package com.graphaware;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.schema.ConstraintCreator;
import org.neo4j.unsafe.batchinsert.BatchInserter;
import org.neo4j.unsafe.batchinsert.BatchInserters;
import java.util.Collections;
import java.util.Date;
@luanne
luanne / LabelTokenIsReferencedTwiceFromSameNode.java
Created February 3, 2015 16:23
When a node is created with duplicate labels by the batch inserter, the consistency checker produces "The label token record is referenced twice from the same node"
package com.graphaware;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.schema.ConstraintCreator;
import org.neo4j.unsafe.batchinsert.BatchInserter;
import org.neo4j.unsafe.batchinsert.BatchInserters;
import java.util.Collections;
import java.util.Date;
@luanne
luanne / recruitment.adoc
Last active August 29, 2015 14:02
Recruitment Graph Model

Recruitment Graph Model

Professionals from the recruiting industry deal with highly interconnected data every day. Making sense of data from various sources in order to match the best candidate for the job is challenging. Companies are now more specific in terms of job profiles and requirements and candidates are more choosy about their roles and responsibilities.

Graphs are a perfect way to model this data. An extremely simple model is depicted in this GraphGist but one can see how it could be extended very naturally to include a much larger variety of data.

@luanne
luanne / cities.adoc
Last active August 29, 2015 14:02
Visiting Cities

Visiting Cities

"I am playing around with Neo4J, and I have nodes of persons and cities visited. Lets say that I have visited London, and I want to see I want to create a query returning all cities that has been visited by more than one of the persons that have visited a city you have visited. However, it must not be a city that you have visited. Whoa, that was a mouthful."

We’ll figure this out in a couple of steps using the data provided:

Setup

@luanne
luanne / animalParty.adoc
Last active August 29, 2015 13:56
Animal Party Graph Gist

Animal Party

Added some more animals (Basilisk) and people (Ron and Harry) to test more conditions. From the description:

"However, my focus is on every person in the shape optionally having none, one two or three set of things[*], one of which contains elements which must ALL be matched by the elements of a provided collection, one of which ANY must be matched, and one which contains elements of which NONE must be matched by anything in the (common) provided collection. Implementing this is a core requirement."

@luanne
luanne / trains.adoc
Last active January 8, 2016 11:29
Bombay Trains graph gist

Bombay Railway Routes

Most people from Bombay have a love-hate relation with trains. While they are still the quickest way to get to almost any place, getting into a train is an entirely different matter. We have beautiful structures such as CST (formerly Victoria Terminus):

cst

and then horrors such as these:

western
@luanne
luanne / drinks.adoc
Last active January 1, 2016 05:49
Christmas Drink GraphGist

Christmas drinks

A reference to mixing christmas drinks

Domain

A drink is composed of ingredients and their quantities. Drinks in this example are divided into alcoholic, non-alcoholic, hot and cold. Ingredients can be added to drinks in various forms such as powdered, whole, crushed etc.

Model

drinks
@luanne
luanne / lms-graph
Last active December 31, 2015 17:39
Organization Learning Graph Gist
= Organization Learning
Learning Management Systems (LMS) are typically deployed in large organizations to support learning processes that align with business goals. These systems tie together their employees, organizations, certifications, courses, jobs in order to supplement business strategy.
This graph gist models a slice of this ecosystem- certification paths and position dependencies on certifications.
== Domain
A certification has one or more learning paths. A learning path is an ordered sequence of items that must be completed in order to acquire the certification. A learning item can be completed by taking a course or proving work experience. A course has a delivery type- it can be web based or classroom. Work Experience specifies the number of hours one must put in to complete it.
To aquire a certification, an employee can take take any learning path and complete every item in it.
Employees hold certifications and complete courses and work experience. An employee may fill a position which require
@luanne
luanne / course-graph.adoc
Last active December 31, 2015 17:39
Course GraphGist

Courses

A graph model for courses and their dependencies

Domain

Institutes conduct courses which are taught by instructors. A course can be taught in multiple languages and/or have subtitles in various languages. A course recommends a min and max amount of study hours per week. Subjects are taught by courses. A subject can have other subjects as prerequisites.

Goal

The model will help us answer the following questions: