Skip to content

Instantly share code, notes, and snippets.

@ernestoe
Forked from swainjo/GreenMan
Last active August 29, 2015 14:06
Show Gist options
  • Save ernestoe/fedd9537cb887ec08fa3 to your computer and use it in GitHub Desktop.
Save ernestoe/fedd9537cb887ec08fa3 to your computer and use it in GitHub Desktop.
== Green Man POC
:neo4j-version: neo4j-2.1
:author: John Swain
:twitter: @swainjo
:tags: domain:POC
=== Load Sample Data
//setup
//hide
[source,cypher]
----
CREATE
(dev1:Person{name:"Alex"}),
(dev2:Person{name:"Maria"}),
(dev3:Person{name:"Pepe"}),
(python:Technology{name:"Python"}),
(go:Technology{name:"Go"}),
(dev1)-[:KNOWS]->(python),
(dev1)-[:KNOWS]->(go),
(dev2)-[:KNOWS]->(python),
(dev3)-[:KNOWS]->(go),
(service1:Service{name:"Service #1"}),
(service2:Service{name:"Service #2"}),
(service1)-[:CONNECTS]->(service2),
(service1)-[:WRITTEN_WITH]->(go),
(service2)-[:WRITTEN_WITH]->(python);
----
=== For the first output we are going just to show everything:
[source,cypher]
//graph
=== Show Python Related
So, what’s the point of all this? Basically, that you can do queries that will make the graph smaller for your needs. This example data that we have added is quite small (just few nodes), in the real graph that I am working on we have already few dozens. For example, imagine that you just want to see python related information:
[source,cypher]
----
MATCH (t)-[r]-(t1)
WHERE t.name="Python"
RETURN t, r, t1;
----
//table
//graph_result
=== Server 1
Or you just want to see the people that can work with the Server #1
[source,cypher]
----
MATCH (s:Service)-[r]-()-[r1:KNOWS]-(p:Person)
WHERE s.name="Service #1"
RETURN s, p;
----
//table
//graph_result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment