Skip to content

Instantly share code, notes, and snippets.

View kbastani's full-sized avatar
💭
Coding

Kenny Bastani kbastani

💭
Coding
View GitHub Profile
@kbastani
kbastani / README.md
Last active August 29, 2015 14:03 — forked from mbostock/.block

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.

@kbastani
kbastani / graph-art-1
Last active August 29, 2015 14:04
Run these Cypher scripts sequentially to generate graph art in Neo4j
MATCH (a), (b)
WHERE id(a) = 10484 AND id(b) = 10546
MATCH p=shortestPath((a)-[*]-(b))
RETURN p
@kbastani
kbastani / gist:6c3df0418d9d61a1a994
Last active August 29, 2015 14:04
The Oregon Brewers Festival is the quintessential celebration of craft beer!
= 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].

== This is a test

@kbastani
kbastani / gist:1f278795b122cff09fd2
Last active August 29, 2015 14:04
graphgist-sharaton
= Neo4j GraphDays =
:neo4j-version: 2.0.1
:author: Kenny Bastani
:twitter: @kennybastani
== Create sample dataset
//setup
//hide
[source,cypher]
----
-s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
@kbastani
kbastani / README.md
Last active August 29, 2015 14:05 — forked from mbostock/.block

Unlike choropleth maps, cartograms encode data using area rather than color, resulting in distorted geographic boundaries. In this example, states are rescaled around their centroid, preserving local shape but not topology. Inspired by Zachary Johnson. Non-continguous cartogram design invented by Judy Olsen. U.S. state and county boundaries from the U.S. Census Bureau, simplified using GDAL and MapShaper.

@kbastani
kbastani / TraversalDescriptionByPath
Last active August 29, 2015 14:06
Filter paths by relationship property condition
/*
* Cypher query:
* MATCH p=(michael:Person { name: "Michael" })-[r:LIKES]->(people)
* WHERE r.weight >= 5
* RETURN p
*/
Transaction tx = db.beginTx();
Node michael = db.findNodesByLabelAndProperty(DynamicLabel.label("Person"), "name", "Michael").iterator().next();
@kbastani
kbastani / Configuration.scala
Last active August 29, 2015 14:11
Apache Spark Importer for generating Neo4j batch inserter CSV files from DBPedia RDF dumps
/**
* Copyright (C) 2014 Kenny Bastani
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
@kbastani
kbastani / gist:4471127413fd724ed0a3
Last active December 30, 2019 03:38
GraphGist of Neo4j Access Control
= Entitlements and Access Control Management
:neo4j-version: 2.2.0
:author: Kenny Bastani
:twitter: @kennybastani
:description: Graph database access control, entitlements, authorization solutions
:tags: domain:finance, use-case:access-control
This interactive Neo4j graph tutorial covers entitlements and access control scenarios.
'''