public
Created

Basic Graphviz

  • Download Gist
gistfile1.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
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 } );
final Node johan = neo.createNode();
johan.setProperty( "!<>)", "!<>)" );
johan.setProperty( "name", "!<>Johan '\\n00b' !<>Svensson" );
final Relationship emilKNOWStobias = emil.createRelationshipTo(
tobias, type.KNOWS );
emilKNOWStobias.setProperty( "since", "2003-08-17" );
final Relationship johanKNOWSemil = johan.createRelationshipTo(
emil, type.KNOWS );
final Relationship tobiasKNOWSjohan = tobias.createRelationshipTo(
johan, type.KNOWS );
final Relationship tobiasWORKS_FORemil = tobias
.createRelationshipTo( emil, type.WORKS_FOR );
OutputStream out = new ByteArrayOutputStream();
GraphvizWriter writer = new GraphvizWriter();
writer.emit( out, Walker.crosscut( emil.traverse( Order.DEPTH_FIRST,
StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL, type.KNOWS,
Direction.BOTH, type.WORKS_FOR, Direction.BOTH ), type.KNOWS, type.WORKS_FOR ) );
tx.success();
System.out.println( out.toString() );
}
finally
{
tx.finish();
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.