Created
May 10, 2012 09:19
-
-
Save peterneubauer/2652082 to your computer and use it in GitHub Desktop.
Basic Graphviz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment