Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Coding

Kenny Bastani kbastani

💭
Coding
View GitHub Profile
@kbastani
kbastani / gist:9009200
Last active Aug 29, 2015
Neo4j Data Modeling Training
View gist:9009200
MERGE (pressly:Person{name:'pressly'})
MERGE (yoom:Person{name:'yoom'})
MERGE (paul:Person{name:'paul'})
MERGE (company:Company{name:'acme'})
MERGE (neo4j:Skill{name:'Neo4j'})
MERGE (rest:Skill{name:'REST'})
MERGE (java:Skill{name:'JAVA'})
MERGE (cpp:Skill{name:'C++'})
MERGE (gremlin:Skill{name:'Gremlin'})
MERGE (ruby:Skill{name:'Ruby'})
@kbastani
kbastani / Reify relationships
Last active Aug 29, 2015
Data Modeling Training San Francisco
View Reify relationships
MATCH (n1:node { n.id = "1234" })
MATCH (n0)-[r1]->(n1)-[r2]->(n2)
DELETE r1, n1, r2
MERGE (n0)-[:NEXT]->(n2)
View Interpolate-Missing-Data-Points
// Create a list of dates to use as data points
// Count the amount of days since the creation date
int dayCount = DateTime.Now.Subtract(createdDate).Days;
// Create an index of data points and calculate linear interpolation for a given point
int[] membershipPoints = new int[dayCount];
for (int i = 0; i < membershipPoints.Length; i++)
{
// Calculate membership count using linear interpolation
View gist:588d53ffc824da4c8b1d

= What is the Neo4j GraphGist project?

:neo4j-version: 2.1.0 :author: Anders Nawroth :twitter: @nawroth :tags: domain:example

http://neo4j.com[Neo4j] GraphGists are an easy way to create and share documents containing not just prose, structure and pictures but most importantly example graph models and use-cases expressed in Neo4j's query language http://docs.neo4j.org/refcard/2.1/[Cypher].

View README.md

Prim’s algorithm generates a minimum spanning tree from a graph with weighted edges. Starting in the bottom-left corner, the algorithm keeps a heap of the possible directions the maze could be extended (shown in pink). At each step, the maze is extended in the direction with the lowest weight, as long as doing so does not reconnect with another part of the maze. Here the edges are initialized with random weights.

Unlike Wilson’s algorithm, this does not result in a uniform spanning tree. Sometimes, random traversal is misleadingly referred to as randomized Prim’s algorithm; however, the two algorithms exhibit radically different behavior! The global structure of the maze can be more easily seen by flooding it with color.

View README.md

The tree layout implements the Reingold-Tilford algorithm for efficient, tidy arrangement of layered nodes. The depth of nodes is computed by distance from the root, leading to a ragged appearance. Cartesian orientations are also supported. Implementation based on work by Jeff Heer and Jason Davies using Buchheim et al.'s linear-time variant of the Reingold-Tilford algorithm. Data shows the Flare class hierarchy, also courtesy Jeff Heer.

Compare to this Cartesian layout.

@kbastani
kbastani / graph-art-1
Last active Aug 29, 2015
Run these Cypher scripts sequentially to generate graph art in Neo4j
View graph-art-1
MATCH (a), (b)
WHERE id(a) = 10484 AND id(b) = 10546
MATCH p=shortestPath((a)-[*]-(b))
RETURN p
@kbastani
kbastani / gist:6c3df0418d9d61a1a994
Last active Aug 29, 2015
The Oregon Brewers Festival is the quintessential celebration of craft beer!
View gist:6c3df0418d9d61a1a994
= Craft Beers Are Everywhere in Portland =
:neo4j-version: 2.1.2
:author: Kenny Bastani
:twitter: @kennybastani
This GraphGist tells a story about why relationships matter and how craft beers seem to be everywhere in Portland.
== Like Graphs, Craft Beers Are Everywhere
Let me first start out by stating that I (http://www.twitter.com/kennybastani[@kennybastani]) am a happy evangelist for the http://www.neo4j.com[Neo4j Graph Database].
View gist:1f278795b122cff09fd2
= Neo4j GraphDays =
:neo4j-version: 2.0.1
:author: Kenny Bastani
:twitter: @kennybastani
== Create sample dataset
//setup
//hide
[source,cypher]
----