## Slides from Chicago Graph Database April Meet-up

Thank you again to Groupon Engineering! They hosted our Graph Database Meet-up at their Headquarters.

Tagged , ,

## Visualizing a set of Hiveplots with Neo4j

What should a graph look like and how can I tell two graphs apart?

## JUNG in Neo4j – Part 1

It’s nice to have an arsenal. In the world of graph databases, one such stock room is the Java Universal Network/Graph Framework(JUNG) which contains a cache of algorithms from graph theory, data mining, and social network analysis, such as routines for clustering, decomposition, optimization, random graph generation, statistical analysis, and calculation of network distances, flows, and importance measures (centrality, PageRank, HITS, etc.).

We can use JUNG via the Blueprints ouplementation and access it via Gremlin. It doesn’t come pre-packaged with Neo4j, but Michael Hunger playing the role of “Tank” and was able to load up our stock room with a few key strokes.

Tagged , , , , ,

## Max Flow with Gremlin and Transactions

The maximum flow problem was formulated by T.E. Harris as follows:

Consider a rail network connecting two cities by way of a number of intermediate cities, where each link of the network has a number assigned to it representing its capacity. Assuming a steady state condition, a nd a maximal flow from one given city to the other.

Back in the mid 1950s the US Military had an interest in finding out how much capacity the Soviet railway network had to move cargo from the Western Soviet Union to Eastern Europe. This lead to the Maximum Flow problem and the Ford–Fulkerson algorithm to solve it.

Tagged , , , , ,

## Who is the Greatest?

I done wrestled with an alligator, I done tussled with a whale, only last week I murdered a rock, injured a stone, hospitalized a brick. I’m so mean I make medicine sick.

He floats like a butterfly and stings like a bee, but is Muhammad Ali truly the greatest? Greater than the Beatles? Greater than Alexander? Greater than Sliced Bread? Let’s find out.

We begin by requiring neography and creating a function to help us create the greats.

```require 'rubygems'
require 'neography'

def create_great(name)
Neography::Node.create("name" => name)
end
```

There are a ton of greats out there, but we’ll keep it simple and create just 8 of the greatest greats.

## Gremlin with Neography

Gremlin is a domain specific language for traversing property graphs. Neo4j is one of the databases that can speak the gremlin language, and as promised I’ll show you how you can use it to implement friend recommendations as well as degrees of separation.

We can send any gremlin script to Neo4j via the REST API and neography using the execute_script command. Let’s implement suggestions_for so it sends a gremlin script to the server:

```def suggestions_for(node)
node_id = node["self"].split('/').last.to_i
@neo.execute_script("g.v(node_id).
in('friends').
in('friends').
dedup.
filter{it != g.v(node_id)}.
name", {:node_id => node_id})
end

puts "Johnathan should become friends with #{suggestions_for(johnathan).join(', ')}"

# RESULT
# Johnathan should become friends with Mary, Phil
```