= Neo4j GraphDays = | |
:neo4j-version: 2.0.1 | |
:author: Kenny Bastani | |
:twitter: @kennybastani | |
== Create sample dataset | |
//setup | |
//hide | |
[source,cypher] | |
---- |
= 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]. |
MATCH (a), (b) | |
WHERE id(a) = 10484 AND id(b) = 10546 | |
MATCH p=shortestPath((a)-[*]-(b)) | |
RETURN p |
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.
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.
= 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].
= Logical Graphs = | |
:neo4j-version: 2.0.3 | |
:author: Kenny Bastani | |
:twitter: @kennybastani | |
image::https://c2.staticflickr.com/4/3034/3047586737_9ba0b25fbf.jpg[Who owns the fish?] | |
There are five houses in five different colours starting from left to right. In each house lives a person of a different nationality. These owners all drink a certain type of beverage, smoke a certain brand of cigarette and keep a certain type of pet. No two owners have the same pet, smoke the same brand or drink the same beverage. The question is: WHO OWNS THE FISH??? | |
== Problem |
// 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 |
using Neo4jClient; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Http; | |
using System.Runtime.Serialization.Json; | |
using System.Text; | |
using System.Threading.Tasks; |