Skip to content

Instantly share code, notes, and snippets.

View peterneubauer's full-sized avatar

Peter Neubauer peterneubauer

View GitHub Profile
#öffne einen neuen Neo4j Graph als den default-Graphen ($_g)
$_g := neo4j:open('tmp/matrix')
#die Knoten mit Namen
$neo := g:add-v()
$neo/name := 'Neo'
$morpheus := g:add-v()
$morpheus/name := 'Morpheus'
$trinity := g:add-v()
$trinity/name := 'Trinity'
$_g := neo4j:open('neodb.neo')
$bob := g:add-v(g:map('name','Bob'))
$john := g:add-v(g:map('name','John'))
$alice := g:add-v(g:map('name','Alice'))
$e1 := g:add-e($bob,'link',$john)
$e2 := g:add-e($john,'link',$alice)
$e3 := g:add-e($alice,'link',$bob)
$e1/weight := 10
$e2/weight := 1
$e3/weight := 20
require "rubygems"
require "neo4j"
class Person
include Neo4j::NodeMixin
# define Neo4j properties
property :name
# define an one way relationship to any other node
require "rubygems"
require "neo4j"
Neo4j::Transaction.run do
cars = Neo4j::Node.new
silver = Neo4j::Node.new
saab = Neo4j::Node.new
year_2000 = Neo4j::Node.new
year_2000[:year] = '2000'
year_2002 = Neo4j::Node.new
@peterneubauer
peterneubauer / gist:866123
Created March 11, 2011 16:24
Custom representation plugin
Depend on
-------------------
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>1.3-SNAPSHOT</version>
</dependency>
-----------------------
package org.neo4j.examples.server.plugins;
@peterneubauer
peterneubauer / gist:1726137
Created February 2, 2012 22:14
Neo4j Hangout 2. Feb 2012 Transcript
Hatim: yeah Peter, looking forward to it
Nigel Small: at least i have text :/
@peterneubauer
peterneubauer / gist:2518979
Created April 28, 2012 13:11
Multithread test
/**
* Licensed to Neo Technology under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Neo Technology licenses this file to you 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
@peterneubauer
peterneubauer / gist:2652082
Created May 10, 2012 09:19
Basic Graphviz
Transaction tx = neo.beginTx();
try
{
final Node emil = neo.createNode();
emil.setProperty( "name", "Emil Eifrém" );
emil.setProperty( "age", 30 );
final Node tobias = neo.createNode();
tobias.setProperty( "name", "Tobias \"thobe\" Ivarsson" );
tobias.setProperty( "age", 23 );
tobias.setProperty( "hours", new int[] { 10, 10, 4, 4, 0 } );
@peterneubauer
peterneubauer / gist:2652088
Created May 10, 2012 09:21
Graphviz output
digraph Neo {
node [
fontname = "Bitstream Vera Sans"
shape = "Mrecord"
fontsize = "8"
]
edge [
fontname = "Bitstream Vera Sans"
fontsize = "8"
]
@peterneubauer
peterneubauer / gist:2871902
Created June 5, 2012 01:36
Slideshow Asciidoc
deck.js and Neo4j docs
======================
== Include a live console ==
Cypher with syntax highlighting and a live console:
[source,cypher]
----
START n=node(1)