Skip to content
This repository
Browse code

staging for release.

  • Loading branch information...
commit 25908b02e96f8d614585311e52723ad230676866 1 parent 47bea22
stephen mallette spmallette authored

Showing 35 changed files with 2,677 additions and 0 deletions. Show diff stats Hide diff stats

  1. +15 0 doc/wiki/Acknowledgments.textile
  2. +82 0 doc/wiki/Batch-Implementation.textile
  3. +92 0 doc/wiki/Code-Examples.textile
  4. +19 0 doc/wiki/Desired-Implementations.textile
  5. +109 0 doc/wiki/Dex-Implementation.textile
  6. +52 0 doc/wiki/Event-Implementation.textile
  7. +124 0 doc/wiki/GML-Reader-and-Writer-Library.textile
  8. +53 0 doc/wiki/Graph-Indices.textile
  9. +22 0 doc/wiki/Graph-Morphisms.textile
  10. +55 0 doc/wiki/Graph-Transactions.textile
  11. +194 0 doc/wiki/GraphML-Reader-and-Writer-Library.textile
  12. +310 0 doc/wiki/GraphSON-Reader-and-Writer-Library.textile
  13. +93 0 doc/wiki/Home.textile
  14. +48 0 doc/wiki/Id-Implementation.textile
  15. +20 0 doc/wiki/Implementations.textile
  16. +7 0 doc/wiki/InfiniteGraph-Implementation.textile
  17. +63 0 doc/wiki/JUNG-Ouplementation.textile
  18. +60 0 doc/wiki/Neo4j-Implementation.textile
  19. +62 0 doc/wiki/Neo4jBatch-Implementation.textile
  20. +17 0 doc/wiki/Neo4jHa-Implementation.textile
  21. +63 0 doc/wiki/OrientDB-Implementation.textile
  22. +7 0 doc/wiki/Ouplementations.textile
  23. +38 0 doc/wiki/Partition-Implementation.textile
  24. +22 0 doc/wiki/Property-Graph-Implementations.textile
  25. +106 0 doc/wiki/Property-Graph-Model-Test-Suite.textile
  26. +25 0 doc/wiki/Property-Graph-Model.textile
  27. +16 0 doc/wiki/ReadOnly-Implementation.textile
  28. +398 0 doc/wiki/Release-Notes.textile
  29. +15 0 doc/wiki/Rexster-Implementation.textile
  30. +113 0 doc/wiki/Sail-Implementation.textile
  31. +198 0 doc/wiki/Sail-Ouplementation.textile
  32. +11 0 doc/wiki/The-Benefits-of-Blueprints.textile
  33. +79 0 doc/wiki/The-Major-Differences-Between-Blueprints-1.x-and-2.x.textile
  34. +54 0 doc/wiki/TinkerGraph.textile
  35. +35 0 doc/wiki/Vertex-Query.textile
15 doc/wiki/Acknowledgments.textile
Source Rendered
... ... @@ -0,0 +1,15 @@
  1 +<img width="100" src="https://github.com/tinkerpop/blueprints/raw/master/doc/images/blueprints-character-2.png"/>
  2 +
  3 +This section provides a list of the people that have contributed in some way to the creation of Blueprints.
  4 +
  5 +# "Marko A. Rodriguez":http://markorodriguez.com -- designed, developed, tested, and documented Blueprints.
  6 +# "Luca Garulli":http://orientechnologies.com -- developed the OrientDB implementatio (@OrientGraph@).
  7 +# "Joshua Shinavier":http://fortytwo.net -- developed Blueprints Sail (@GraphSail@).
  8 +# "Darrick Weibe":http://github.com/pangloss -- tests, bug fixes, and transaction work.
  9 +# "Stephen Mallette":http://stephen.genoprime.com -- develops @RexsterGraph@ and other components.
  10 +# "Sergio Gómez Villamor":http://github.com/sgomezvillamor -- developed the Dex implementation (@DexGraph@).
  11 +# "Pierre De Wilde":http://www.linkedin.com/in/pierredewilde -- designs and tests new features.
  12 +# "Ketrina Yim":http://www.ketrinayim.com/ -- designed the Blueprints logo.
  13 +# "Matthias Broecheler":http://www.matthiasb.com/ -- designed many of the TinkerPop 2 API changes.
  14 +
  15 +Please review Blueprints' "pom.xml":http://github.com/tinkerpop/blueprints/blob/master/pom.xml. Blueprints would not be possible without the work done by others to create these useful packages.
82 doc/wiki/Batch-Implementation.textile
Source Rendered
... ... @@ -0,0 +1,82 @@
  1 +[[http://www.stacymakescents.com/wp-content/uploads/haystack-clip-art.gif|width=250px]]
  2 +
  3 +```xml
  4 +<dependency>
  5 + <groupId>com.tinkerpop.blueprints</groupId>
  6 + <artifactId>blueprints-core</artifactId>
  7 + <version>??</version>
  8 +</dependency>
  9 +```
  10 +
  11 +@BatchGraph@ wraps any @TransactionalGraph@ to enable batch loading of a large number of edges and vertices by chunking the entire load into smaller batches and maintaining a memory-efficient vertex cache so that intermediate transactional states can be flushed after each chunk is loaded to release memory.
  12 +
  13 +
  14 +@BatchGraph@ is *ONLY* meant for loading data and does not support any retrieval or removal operations. That is, BatchGraph only supports the following methods:
  15 +* @addVertex()@ for adding vertices
  16 +* @addEdge()@ for adding edges
  17 +* @getVertex()@ to be used when adding edges
  18 +* Property getter, setter and removal methods for vertices and edges as well as @getId()@
  19 +
  20 +An important limitation of @BatchGraph@ is that edge properties can only be set immediately after the edge has been added. If other vertices or edges have been created in the meantime, setting, getting or removing properties will throw exceptions. This is done to avoid caching of edges which would require a great amount of memory.
  21 +
  22 +@BatchGraph@ wraps @TransactionalGraph@. To wrap arbitrary graphs, use @BatchGraph.wrap()@ which will additionally wrap non-transactional graphs.
  23 +
  24 +@BatchGraph@ can also automatically set the provided element ids as properties on the respective element. Use @setVertexIdKey()@ and @setEdgeIdKey()@ to set the keys for the vertex and edge properties respectively. This is useful when the graph implementation ignores supplied ids and allows to make the loaded graph compatible for later wrapping with @IdGraph@ (see [[Id Implementation]]) when setting the vertex and edge Id keys to @IdGraph.ID@.
  25 +
  26 +As an example, suppose we are loading a large number of edges defined by a String array with four entries called _quads_:
  27 +
  28 +# The out vertex id
  29 +# The in vertex id
  30 +# The label of the edge
  31 +# A string annotation for the edge, i.e. an edge property
  32 +
  33 +Assuming this array is very large, loading all these edges in a single transaction is likely to exhaust main memory. Furthermore,
  34 +one would have to rely on the database indexes to retrieve previously created vertices for a given id. @BatchGraph@ addresses
  35 +both of these issues.
  36 +
  37 +```java
  38 +BatchGraph bgraph = new BatchGraph(graph, BatchGraph.IdType.STRING, 1000);
  39 +for (String[] quad : quads) {
  40 + Vertex[] vertices = new Vertex[2];
  41 + for (int i=0;i<2;i++) {
  42 + vertices[i] = bgraph.getVertex(quad[i]);
  43 + if (vertices[i]==null) vertices[i]=bgraph.addVertex(quad[i]);
  44 + }
  45 + Edge edge = bgraph.addEdge(null,vertices[0],vertices[1],quad[2]);
  46 + edge.setProperty("annotation",quad[3]);
  47 +}
  48 +```
  49 +
  50 +First, a @BatchGraph@ _bgraph_ is created wrapping an existing _graph_ and setting the id type to @IdType.STRING@ and the batch size to 1000.
  51 +@BatchGraph@ maintains a mapping from the external vertex ids, in our example the first two entries in the String array describing th edge,
  52 +to the internal vertex ids assigned by the wrapped grahp database. Since this mapping is maintained in memory, it is potentially much faster
  53 +than the database index. By specifying the @IdType@, @BatchGraph@ chooses the most memory-efficient mapping data structure and applies compression
  54 +algorithms if possible. There are four different @IdTypes@:
  55 +
  56 +* _OBJECT_ : For arbitrary object vertex ids. This is the most generic and least space efficient type.
  57 +* _STRING_ : For string vertex ids. Attempts to apply string compression and prefixing strategies to reduce the memory footprint.
  58 +* _URL_ : For string vertex ids that parse as URLs. Applies URL specific compression schemes that are more efficient than generic string compression.
  59 +* _NUMBER_ : For numeric vertex ids. Uses primitive data structures that requires significantly less memory.
  60 +
  61 +The last argument in the constructor is the batch size, that is, the number of vertices and edges to load before committing a transaction and starting a
  62 +new one.
  63 +
  64 +The for-loop then iterates over all the quad String arrays and creates an edge for each by first retrieving or creating the vertex end points
  65 +and then creating the edge. Note, that we set the edge property immediately after creating the edge. This is required because
  66 +edges are only kept in memory until the next edge is created for efficiency reasons.
  67 +
  68 +h2. Incremental Loading
  69 +
  70 +The above describes how @BatchGraph@ can be used to load data into a graph under the assumption that the wrapped graph is initially empty. @BatchGraph@ can also be used to incrementally batch load edges and vertices into a graph with existing data. In this case, vertices may already exist for given ids.
  71 +
  72 +If the wrapped graph does not ignore ids, then enabling incremental batch loading is as simple as calling @setLoadingFromScratch(false)@, i.e. to disable the assumption that data is loaded into an empty graph. If the wrapped graph does ignore ids, then one has to tell @BatchGraph@ how to find existing vertices for a given id by specifying the vertex id key using @setVertexIdKey(uid)@ where _uid_ is some string for the property key. Also, uid must be "key indexed":https://github.com/tinkerpop/blueprints/wiki/Graph-Indices for this to work.
  73 +
  74 +```java
  75 +graph.createKeyIndex("uid",Vertex.class);
  76 +BatchGraph bgraph = new BatchGraph(graph, BatchGraph.IdType.STRING, 1000);
  77 +bgraph.setVertexIdKey("uid);
  78 +bgraph.setLoadingFromScratch(false);
  79 +//Load data as shown above
  80 +```
  81 +
  82 +Note, that incremental batch loading is more expensive than loading from scratch because @BatchGraph@ has to call on the wrapped graph to determine whether a vertex exists for a given id.
92 doc/wiki/Code-Examples.textile
Source Rendered
... ... @@ -0,0 +1,92 @@
  1 +This section will provide a collection of basic code examples that work with the Blueprints graph API. The in-memory [[TinkerGraph]] database will be used throughout the examples. Please feel free to alter the graph constructor to work with different graph databases.
  2 +
  3 +# "Create a Simple Graph":#create
  4 +# "Iterate through the Elements of a Graph":#elements
  5 +# "Iterate through the Edges of a Vertex":#edge
  6 +
  7 +<a name="create"></a>
  8 +
  9 +h2(#create). Create a Simple Graph
  10 +
  11 +Create a graph. Add two vertices. Set the @name@ property of each vertex. Create an @knows@ edge between the two vertices. Print the components of the graph.
  12 +
  13 +```java
  14 +import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
  15 +import com.tinkerpop.blueprints.Graph;
  16 +import com.tinkerpop.blueprints.Vertex;
  17 +import com.tinkerpop.blueprints.Edge;
  18 +import com.tinkerpop.blueprints.Direction;
  19 +
  20 +Graph graph = new TinkerGraph();
  21 +Vertex a = graph.addVertex(null);
  22 +Vertex b = graph.addVertex(null);
  23 +a.setProperty("name", "marko");
  24 +b.setProperty("name", "peter");
  25 +Edge e = graph.addEdge(null, a, b, "knows");
  26 +System.out.println(e.getVertex(Direction.OUT).getProperty("name") + "--" + e.getLabel() + "-->" + e.getVertex(Direction.IN).getProperty("name"));
  27 +```
  28 +
  29 +The @System.out@ after the code executes is:
  30 +
  31 +bc. marko--knows-->peter
  32 +
  33 +<a name="elements"></a>
  34 +
  35 +h2(#elements). Iterate through the Elements of a Graph
  36 +
  37 +Load the TinkerPop play graph diagrammed in [[Property Graph Model]]. Iterate through all the vertices and print them to @System.out@. Iterate through all the edges and print them to @System.out@.
  38 +
  39 +```java
  40 +public void testIteratingGraph() {
  41 + Graph graph = TinkerGraphFactory.createTinkerGraph();
  42 + System.out.println("Vertices of " + graph);
  43 + for (Vertex vertex : graph.getVertices()) {
  44 + System.out.println(vertex);
  45 + }
  46 + System.out.println("Edges of " + graph);
  47 + for (Edge edge : graph.getEdges()) {
  48 + System.out.println(edge);
  49 + }
  50 +}
  51 +```
  52 +
  53 +The @System.out@ after the code executes is:
  54 +
  55 +bc. Vertices of tinkergraph[vertices:6 edges:6]
  56 +v[3]
  57 +v[2]
  58 +v[1]
  59 +v[6]
  60 +v[5]
  61 +v[4]
  62 +Edges of tinkergraph[vertices:6 edges:6]
  63 +e[10][4-created->5]
  64 +e[7][1-knows->2]
  65 +e[9][1-created->3]
  66 +e[8][1-knows->4]
  67 +e[11][4-created->3]
  68 +e[12][6-created->3]
  69 +
  70 +<a name="edge"></a>
  71 +
  72 +h2(#edge). Iterate through the Edges of a Vertex
  73 +
  74 +Load the TinkerPop play graph diagrammed in [[Property Graph Model]]. Get vertex @1@ from the graph by its @id@. Print some information about the vertex. Iterate through the outgoing edges of the vertex and print the edges.
  75 +
  76 +```java
  77 +Graph graph = TinkerGraphFactory.createTinkerGraph();
  78 +Vertex a = graph.getVertex("1");
  79 +System.out.println("vertex " + a.getId() + " has name " + a.getProperty("name"));
  80 +for(Edge e : a.getEdges(OUT)) {
  81 + System.out.println(e);
  82 +}
  83 +```
  84 +
  85 +The @System.out@ after the code executes is:
  86 +
  87 +bc. vertex 1 has name marko
  88 +e[7][1-knows->2]
  89 +e[9][1-created->3]
  90 +e[8][1-knows->4]
  91 +
  92 +<a name="index"></a>
19 doc/wiki/Desired-Implementations.textile
Source Rendered
... ... @@ -0,0 +1,19 @@
  1 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/blueprints-bob-the-builder.png!
  2 +
  3 +It is a time consuming process to maintain Blueprints implementations as graph database/framework versions and features change. Many developers focusing on a particular implementation is an ideal way of ensuring that Blueprints has wide reach and is always consistent with the latest developments. If there is a graph database/framework that is currently not supported by Blueprints and you are an expert with that system, please contribute an implementation. To get a feel of what is required, see [[Property Graph Model]] and [[Property Graph Model Test Suite]].
  4 +
  5 +Below is a list of desired implementations. This list is not intended to be exhaustive. Please feel free to add to the list.
  6 +
  7 +* "db4o":http://developer.db4o.com
  8 +* "Versant Object Database":http://www.versant.com
  9 +* "InfoGrid":http://infogrid.org/
  10 +* "vertexdb":http://www.dekorte.com/projects/opensource/vertexdb/
  11 +* "Redis":http://code.google.com/p/redis/ - see "Blueredis":https://github.com/dmitriid/blueredis
  12 +* "AvocadoDB":http://www.avocadodb.org/
  13 +* "Lucene":http://lucene.apache.org/core/ - see "Lumeo":https://github.com/karussell/lumeo
  14 +* "Azure Table Storage":http://www.windowsazure.com/en-us/home/features/storage/
  15 +* Sail-based RDF Stores (very easy to do as only a @Sail@ constructor is needed)
  16 +** "4Store":http://4store.org/
  17 +** "AllegroGraph":http://www.franz.com/agraph/allegrograph/
  18 +** "OpenVirtuoso":http://virtuoso.openlinksw.com/
  19 +** "OWLim":http://www.ontotext.com/owlim/
109 doc/wiki/Dex-Implementation.textile
Source Rendered
... ... @@ -0,0 +1,109 @@
  1 +[[http://www.sparsity-technologies.com/images/sparsity_logo_web.png]]
  2 +
  3 +```xml
  4 +<dependency>
  5 + <groupId>com.tinkerpop.blueprints</groupId>
  6 + <artifactId>blueprints-dex-graph</artifactId>
  7 + <version>??</version>
  8 +</dependency>
  9 +```
  10 +
  11 +```java
  12 +Graph graph = new DexGraph("/tmp/graph.dex");
  13 +```
  14 +
  15 +"Dex":http://www.sparsity-technologies.com/dex is a graph database developed by "Sparsity Technologies":http://www.sparsity-technologies.com/. For a fine summary of the Dex graph database, please review the following "presentations":http://www.sparsity-technologies.com/dex_tutorials. The software can be downloaded from "here":http://www.sparsity-technologies.com/dex_downloads and be used with the default evaluation license (which restricts the amount of information Dex can deal with).
  16 +
  17 +h2. Vertex label
  18 +
  19 +As edges, Dex vertices have a label too. Thus, when adding a vertex to the database, its label can be set as follows:
  20 +
  21 +```java
  22 +((DexGraph)graph).label.set("people");
  23 +Vertex v = graph.addVertex(null)
  24 +assertTrue(v.getProperty(StringFactory.LABEL).equals("people"));
  25 +```
  26 +
  27 +The @DexGraph#label@ property is also relevant for other methods. Go to the javadoc of each of the following methods to see how:
  28 +* @DexGraph#addVertex@
  29 +* @DexGraph#createKeyIndex(String, Class<T>)@
  30 +* @DexGraph#getEdges(String, Object)@
  31 +* @DexGraph#getVertices(String, Object)@
  32 +
  33 +h2. Memory Configuration
  34 +
  35 +Dex memory is not managed by the JVM heap, so an specific memory configuration must be set for Dex in order to set the maximum amount of memory to be used by a Dex application.
  36 +
  37 +Specifically, users should set @dex.io.cache.maxsize@ as is explained [[here|http://www.sparsity-technologies.com/downloads/javadoc-java/com/sparsity/dex/gdb/DexConfig.html]].
  38 +
  39 +h2. Managment of @Iterable@ collections
  40 +
  41 +As before, since Dex resources are not managed by the JVM heap, Dex-based blueprints applications should take into account the management of @Iterable@ collections and explicitly close them in order to free native resources.
  42 +
  43 +For example, if we execute a long traversal like this:
  44 +
  45 +```java
  46 +for (final Vertex vertex : graph.getVertices()) {
  47 + for (final Edge edge : vertex.getOutEdges()) {
  48 + final Vertex vertex2 = edge.getInVertex();
  49 + for (final Edge edge2 : vertex2.getOutEdges()) {
  50 + ...
  51 + }
  52 + }
  53 +}
  54 +```
  55 +
  56 +all retrieved collections won't be closed until the graph database is stopped. Of course, keep active this amount of resources will have a negative impact in the performance.
  57 +
  58 +To avoid this, all retrieved collections from methods in the Dex implementation implement @CloseableIterable@. Thus, we could implement the previous traversal as follows:
  59 +
  60 +```java
  61 +CloseableIterable<Vertex> vv = (CloseableIterable<Vertex>)graph.getVertices();
  62 +for (final Vertex vertex : vv) {
  63 + CloseableIterable<Edge> ee = (CloseableIterable<Edge>)vertex.getOutEdges();
  64 + for (final Edge edge : ee) {
  65 + final Vertex vertex2 = edge.getInVertex();
  66 + CloseableIterable<Edge> ee2 = (CloseableIterable<Edge>)vertex2.getOutEdges();
  67 + for (final Edge edge2 : ee2) {
  68 + ...
  69 + }
  70 + ee2.close();
  71 + }
  72 + ee.close();
  73 +}
  74 +vv.close();
  75 +```
  76 +
  77 +h2. DexGraph Feature List
  78 +
  79 +```
  80 +supportsDuplicateEdges = true;
  81 +supportsSelfLoops = true;
  82 +isPersistent = true;
  83 +isRDFModel = false;
  84 +supportsVertexIteration = true;
  85 +supportsEdgeIteration = true;
  86 +supportsVertexIndex = false;
  87 +supportsEdgeIndex = false;
  88 +ignoresSuppliedIds = true;
  89 +supportsTransactions = false;
  90 +supportsIndices = false;
  91 +
  92 +supportsSerializableObjectProperty = false;
  93 +supportsBooleanProperty = true;
  94 +supportsDoubleProperty = true;
  95 +supportsFloatProperty = true;
  96 +supportsIntegerProperty = true;
  97 +supportsPrimitiveArrayProperty = false;
  98 +supportsUniformListProperty = false;
  99 +supportsMixedListProperty = false;
  100 +supportsLongProperty = false;
  101 +supportsMapProperty = false;
  102 +supportsStringProperty = true;
  103 +
  104 +isWrapper = false;
  105 +supportsKeyIndices = true;
  106 +supportsVertexKeyIndex = true;
  107 +supportsEdgeKeyIndex = true;
  108 +supportsThreadedTransactions = false;
  109 +```
52 doc/wiki/Event-Implementation.textile
Source Rendered
... ... @@ -0,0 +1,52 @@
  1 +```xml
  2 +<dependency>
  3 + <groupId>com.tinkerpop.blueprints</groupId>
  4 + <artifactId>blueprints-core</artifactId>
  5 + <version>??</version>
  6 +</dependency>
  7 +```
  8 +
  9 +@EventGraph@ and @EventIndexableGraph@ wrap any @Graph@ or @IndexableGraph@, respectively. The purpose of an @EventGraph@ is to raise events to one or more @GraphChangedListener@ as changes to the underlying @Graph@ occur. The obvious limitation is that events will only be raised to listeners if the changes to the @Graph@ occur within the same process.
  10 +
  11 +@EventTransactionalGraph@ and @EventTransactionalIndexableGraph@ wrap any @TransactionalGraph@. These wrappers behave in the same fashion as the aforementioned @EventGraph@ and @EventIndexableGraph@, but respect the concept of transactions, such that the events that are triggered during a transaction are queued until the transaction is successfully committed. Once committed, the events will fire in the order that they were queued. If the transaction is rolled back the event queue is reset.
  12 +
  13 +The following events are raised:
  14 +
  15 +* New vertex
  16 +* New edge
  17 +* Vertex property changed
  18 +* Edge property changed
  19 +* Vertex property removed
  20 +* Edge property removed
  21 +* Vertex removed
  22 +* Edge removed
  23 +* Graph cleared
  24 +
  25 +To start processing events from a @Graph@ first implement the @GraphChangedListener@ interface. An example of this implementation is the @ConsoleGraphChangedListener@ which writes output to the console for each event.
  26 +
  27 +To add a listener to the @EventGraph@:
  28 +
  29 +```java
  30 +EventGraph graph = new EventGraph(TinkerGraphFactory.createTinkerGraph());
  31 +graph.addListener(new ConsoleGraphChangedListener(graph));
  32 +
  33 +Vertex v = graph.addVertex(100);
  34 +v.setProperty("name", "noname");
  35 +
  36 +for (Edge edge : graph.getEdges()) {
  37 + edge.removeProperty("weight");
  38 +}
  39 +```
  40 +
  41 +The following output would appear in the console:
  42 +
  43 +```text
  44 +Vertex [v[100]] added to graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  45 +Vertex [v[4]] property [name] set to value of [noname] in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  46 +Edge [e[10][4-created->5]] property [weight] with value of [1.0] removed in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  47 +Edge [e[7][1-knows->2]] property [weight] with value of [0.5] removed in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  48 +Edge [e[9][1-created->3]] property [weight] with value of [0.4] removed in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  49 +Edge [e[8][1-knows->4]] property [weight] with value of [1.0] removed in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  50 +Edge [e[11][4-created->3]] property [weight] with value of [0.4] removed in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  51 +Edge [e[12][6-created->3]] property [weight] with value of [0.2] removed in graph [eventgraph[tinkergraph[vertices:6 edges:6]]]
  52 +```
124 doc/wiki/GML-Reader-and-Writer-Library.textile
Source Rendered
... ... @@ -0,0 +1,124 @@
  1 +```xml
  2 +<dependency>
  3 + <groupId>com.tinkerpop.blueprints</groupId>
  4 + <artifactId>blueprints-core</artifactId>
  5 + <version>??</version>
  6 +</dependency>
  7 +```
  8 +
  9 +The "GML":http://www.fim.uni-passau.de/en/fim/faculty/chairs/theoretische-informatik/projects.html reader and writer package allows an entire graph to be streamed to and from GML (Graph Modelling Language).
  10 +
  11 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/graph-example-1.jpg!
  12 +
  13 +The following example shows the format of the graph diagram above in GML:
  14 +
  15 +```text
  16 +graph [
  17 + node [
  18 + id 1
  19 + blueprintsId "3"
  20 + name "lop"
  21 + lang "java"
  22 + ]
  23 + node [
  24 + id 2
  25 + blueprintsId "2"
  26 + name "vadas"
  27 + age 27
  28 + ]
  29 + node [
  30 + id 3
  31 + blueprintsId "1"
  32 + name "marko"
  33 + age 29
  34 + ]
  35 + node [
  36 + id 4
  37 + blueprintsId "6"
  38 + name "peter"
  39 + age 35
  40 + ]
  41 + node [
  42 + id 5
  43 + blueprintsId "5"
  44 + name "ripple"
  45 + lang "java"
  46 + ]
  47 + node [
  48 + id 6
  49 + blueprintsId "4"
  50 + name "josh"
  51 + age 32
  52 + ]
  53 + edge [
  54 + source 6
  55 + target 5
  56 + label "created"
  57 + blueprintsId "10"
  58 + weight 1.0
  59 + ]
  60 + edge [
  61 + source 3
  62 + target 2
  63 + label "knows"
  64 + blueprintsId "7"
  65 + weight 0.5
  66 + ]
  67 + edge [
  68 + source 3
  69 + target 1
  70 + label "created"
  71 + blueprintsId "9"
  72 + weight 0.4
  73 + ]
  74 + edge [
  75 + source 3
  76 + target 6
  77 + label "knows"
  78 + blueprintsId "8"
  79 + weight 1.0
  80 + ]
  81 + edge [
  82 + source 6
  83 + target 1
  84 + label "created"
  85 + blueprintsId "11"
  86 + weight 0.4
  87 + ]
  88 + edge [
  89 + source 4
  90 + target 1
  91 + label "created"
  92 + blueprintsId "12"
  93 + weight 0.2
  94 + ]
  95 +]
  96 +```
  97 +
  98 +h1. Usage
  99 +
  100 +To output a graph in GML format, pass the graph into the @GMLWriter@ constructor, then call @outputGraph@:
  101 +
  102 +```java
  103 +Graph graph = ...
  104 +OutputStream out = ...
  105 +
  106 +GMLWriter.outputGraph(graph, out);
  107 +```
  108 +
  109 +The @GMLReader@ works in a similar format. Simply pass what would likely be an empty graph into the constructor, then call @inputGraph@:
  110 +
  111 +```java
  112 +Graph graph = ...
  113 +InputStream in = ...
  114 +
  115 +GMLReader.inputGraph(graph, in);
  116 +```
  117 +By default, the @id@ property is used for vertex and edge ids. In GML edges may not have id, in this case an integer id will be generated. The @label@ property is used for edge labels and "undefined" if not present. The properties used for the vertex id, the edge id and the edge label can be set using.
  118 +
  119 +```java
  120 +reader.setVertexId("propertyToUseAsVertexId");
  121 +reader.setEdgeId("propertyToUseAsEdgeId");
  122 +reader.setEdgeLabel("propertyToUseAsEdgeLabel");
  123 +```
  124 +If set manually the reader assumes that the ids are unique. There are a number of static method overloads that offer more options and control.
53 doc/wiki/Graph-Indices.textile
Source Rendered
... ... @@ -0,0 +1,53 @@
  1 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/indices-example.png!
  2 +
  3 +And index is a data structure that supports the fast lookup of elements by some key/value pair. Lookups are usually in @log(n)@ time where @n@ is the number of elements in the index. There are two types of indexing structures supported by Blueprints. These are reflected in the two respective interfaces: @KeyIndexableGraph@ and @IndexableGraph@.
  4 +
  5 +h2. KeyIndexableGraph and Fast LookUp of Elements by Key/Value Pairs
  6 +
  7 +A @KeyIndexableGraph@ is a graph that supports the automatic indexing of a vertex or edges by its key/value pair properties. When a method requires access to an element by a key/value, then an appropriate key index can be retrieved. Otherwise, a linear scan must take place. Such methods include @Graph.getVertices(String key, Object value)@ and @Graph.getEdges(String key, Object value)@. The methods of @KeyIndexableGraph@ are provided below.
  8 +
  9 +```java
  10 +public <T extends Element> void dropKeyIndex(String key, Class<T> elementClass);
  11 +public <T extends Element> void createKeyIndex(String key, Class<T> elementClass);
  12 +public <T extends Element> Set<String> getIndexedKeys(Class<T> elementClass);
  13 +```
  14 +
  15 +h2. IndexableGraph and Putting, Getting, and Removing Elements
  16 +
  17 +An @IndexableGraph@ is a @Graph@ that supports the indexing of its vertices and edges. An index is a data structure that allows for the fast retrieval of an element by a particular key/value pair. The @IndexableGraph@ interface has the following methods:
  18 +
  19 +```java
  20 +public <T extends Element> Index<T> createIndex(String indexName, Class<T> indexClass, Parameter... indexParameters);
  21 +public <T extends Element> Index<T> getIndex(String indexName, Class<T> indexClass);
  22 +public Iterable<Index<? extends Element>> getIndices();
  23 +public void dropIndex(String indexName);
  24 +```
  25 +
  26 +An index requires the developer to manually put, get, and remove elements from the index. To create a manual index of vertices, do the following:
  27 +
  28 +```java
  29 +Index<Vertex> index = graph.createIndex("test-idx", Vertex.class);
  30 +```
  31 +
  32 +The @Index@ interface has the following methods:
  33 +
  34 +```java
  35 +public long count(String key, Object value);
  36 +public String getIndexName();
  37 +public Class<T> getIndexClass();
  38 +public void put(String key, Object value, T element);
  39 +public Iterable<T> get(String key, Object value);
  40 +public Iterable<T> query(String key, Object value);
  41 +public void remove(String key, Object value, T element);
  42 +```
  43 +
  44 +Given the @index@ object created previous, to add, get, query, and remove a vertex from this index, do the following:
  45 +
  46 +```java
  47 +index.put("name","peter",vertex);
  48 +Iterable<Vertex> results = index.get("name","peter");
  49 +Iterable<Vertex> results = index.query("name", "PeTeR"); // assuming some case-insensitive index
  50 +index.remove("name","peter",vertex);
  51 +```
  52 +
  53 +Finally, The index construction method @createIndex()@ has a @Parameter@ "var arg" as its final argument. Some underlying graph implementations support the passing of parameters to tweak the underlying indexing model -- e.g. case insensitive querying. Please refer to the specifics of each @IndexableGraph@ implementation for their respective support parameters.
22 doc/wiki/Graph-Morphisms.textile
Source Rendered
... ... @@ -0,0 +1,22 @@
  1 +In the world of graphs, there are numerous "graph types":http://en.wikipedia.org/wiki/Graph_%28mathematics%29. The diagram below describes the important feature of a collection of common graph types. Note that many of these types can be mixed and matched. For example, the [[property graph model]] of Blueprints can be seen as a *vertex/edge-labeled/attributed, directed, multi-graph*.
  2 +
  3 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/graph-types.jpg!
  4 +
  5 +* *half-edge graph*: a unary edge graph where an edge connects only one vertex.
  6 +* *multi-graph*: when edges are labeled, the various ways in which vertices are related can be denoted.
  7 +* *simple graph*: the prototypical graph where an edge connects two vertices and no loops are allowed.
  8 +* *weighted graph*: used to represent strength of ties or transition probabilities.
  9 +* *vertex-labeled graph*: most every graph makes use of labeled vertices (e.g. an identifier)
  10 +* *semantic graph*: used to model cognitive structures such as the relationship between concepts and instances of a concept.
  11 +* *vertex-attributed*: used in applications where it is desirable to append non-relational metadata to a vertex.
  12 +* *edge-labeled graph*: provides the ability to denote the way in which two vertices are related (e.g. friendships, kinships, etc.).
  13 +* *directed graph*: orders the vertices connected by an edge to denote directionality.
  14 +* *hypergraph*: generalizes a binary graph to allow an edge to connect to an arbitrary number of vertices.
  15 +* *undirected graph*: the typical graph that is used when the relationship is symmetrical (e.g. friendship).
  16 +* *resource description framework graph*: a graph standard developed by the the World Wide Web consortium that denotes vertices and edges by Uniform Resource Identifiers (see [[Sail Implementation]] and [[Sail Ouplementation]]).
  17 +* *edge-attributed graph*: used in applications where its desirable to append non-relational metadata to an edge.
  18 +* *pseudo graph*: generally allowed in most disciplines to denote a reflexive relationship.
  19 +
  20 +The [[property graph model]] is a convenient graph data model as it is easy to represent other graph types. The following diagram provides the "morphisms":http://en.wikipedia.org/wiki/Morphism that go from one graph type to another. Note that a "hypergraph":http://en.wikipedia.org/wiki/Hypergraph can be modeled using a property graph, though its not as straightforward as modeling other graph types.
  21 +
  22 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/graph-types-morphisms.jpg!
55 doc/wiki/Graph-Transactions.textile
Source Rendered
... ... @@ -0,0 +1,55 @@
  1 +A @Graph@ that implements the @TransactionalGraph@ or @ThreadedTransactionalGraph@ interfaces must natively support "transaction handling":http://en.wikipedia.org/wiki/Database_transaction. A transaction describes a coherent and complete unit of work comprised of multiple read and write operations to be executed against the database together or not at all. In addition, transactions are needed to handle conflicts and consistency issues that arise when multiple users interact with the @Graph@ concurrently. The exact "ACID":http://en.wikipedia.org/wiki/ACID and "isolation":http://en.wikipedia.org/wiki/Isolation_(database_systems) level guarantees extended by a @TransactionalGraph@ or @ThreadedTransactionalGraph@ depend on the specific implementation.
  2 +
  3 +h2. TransactionalGraph and Starting and Stopping Transactions
  4 +
  5 +A @TransactionalGraph@ has just one method for terminating the transaction:
  6 +
  7 +```java
  8 +public void stopTransaction(Conclusion conclusion);
  9 +```
  10 +
  11 +Transactions are automatically started with the first operation on the graph, that is, any read or write operation. Transactions need to be manually closed to mark the end of a transactional context and to inform the graph database whether the transaction was successful or not, by passing @Conclusion.SUCCESS@ or @Conclusion.FAILURE@ to @stopTransaction@, respectively.
  12 +
  13 +Transactions are bound to the current thread, which means that any graph operation executed by the thread occurs in the context of that transaction and that there may only be one thread executing in a single transaction. For thread independent transactions that allow concurrent thread access, use @ThreadedTransactionalGraph@.
  14 +
  15 +When a transaction is started, all the subsequent read and write operations occur within this transaction context. When the transaction is successfully stopped, those mutations operations are persisted and visible to other contexts interacting with the graph and all locks are released. If a transaction is failed, then the mutation operations are "rolled back" to when the transaction was started.
  16 +
  17 +@TransactionalGraph@ makes no assumptions about how transactions are implemented by a graph database. Hence, a transaction may fail at any point if a conflict arises that could not be resolved.
  18 +
  19 +Note, that a @TransactionalGraph.shutdown()@ will automatically successfully commit any open transaction. Also note, that keeping transactions open for a long time may result in @OutOfMemoryException@ if too many mutations have occurred and possible dead-locks if locks are held for too long in multi-user environments.
  20 +
  21 +Note, that element references created in a transactional context may not be accessed outside the transactional context. Doing so may cause an exception. A transaction marks a complete unit of work and after it is stopped, its state may be discarded. Moreover, concurrently running transaction can render such references out-of-sync. Any references created during the transaction may therefore no longer be alive. Hence, the following code snippet may cause an exception:
  22 +
  23 +```java
  24 +Vertex v = graph.addVertex(null);
  25 +//More operations inside the transaction
  26 +stopTransaction(Conclusion.SUCCESS);
  27 +//Other code
  28 +v.setProperty("name","marko");
  29 +```
  30 +
  31 +In such cases, the transactional context should be extended until all operations have been completed. In other words, the @stopTransaction(Conclusion.SUCCESS)@ call should be moved after the @v.setProperty("name","marko");@ write operation.
  32 +In cases where the element reference needs to be accessed outside its original transactional context, it should be re-instantiated based on the element id. For example:
  33 +
  34 +```java
  35 +Vertex v = graph.addVertex(null);
  36 +//More operations inside the transaction
  37 +stopTransaction(Conclusion.SUCCESS);
  38 +//Other code
  39 +startTransaction();
  40 +v = graph.getVertex(v.getId());
  41 +v.setProperty("name","marko");
  42 +```
  43 +
  44 +h2. ThreadedTransactionalGraph and Multi-Threads for One Transaction
  45 +
  46 +@ThreadedTransactionalGraph@ provides more fine grained control over the transactional context. While @TransactionalGraph@ binds each transaction to the executing thread, @ThreadedTransactionalGraph.startTransaction()@ returns a @TransactionalGraph@ that represents its own transactional context independent of the executing thread.
  47 +Hence, one can have multiple threads operating against a single transaction represented by the returned TransactionalGraph object. This is useful for parallelizing graph algorithms.
  48 +
  49 +A @ThreadedTransactionalGraph@ extends @TransactionalGraph@ with a single method.
  50 +
  51 +```java
  52 +public TransactionalGraph startThreadTransaction()
  53 +```
  54 +
  55 +The returned transaction represented by a @TransactionalGraph@ object needs to be explicitly closed by calling @TransactionalGraph.stopTransaction(Conclusion conclusion)@. Calling @TransactionalGraph.shutdown()@ will successfully commit the transaction without closing the underlying graph database.
194 doc/wiki/GraphML-Reader-and-Writer-Library.textile
Source Rendered
... ... @@ -0,0 +1,194 @@
  1 +```xml
  2 +<dependency>
  3 + <groupId>com.tinkerpop.blueprints</groupId>
  4 + <artifactId>blueprints-core</artifactId>
  5 + <version>??</version>
  6 +</dependency>
  7 +```
  8 +
  9 +Besides being able to query and manipulate the underlying data management system with Blueprints, a "GraphML":http://graphml.graphdrawing.org reader and writer package is provided with Blueprints for streaming XML graph representations into and out of the underlying graph framework. The GraphML package uses "StAX":http://stax.codehaus.org to process a GraphML graph. This section discusses the use of the GraphML library for reading and writing XML-encoded graphs.
  10 +
  11 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/graph-example-1.jpg!
  12 +
  13 +Below is the GraphML representation of the graph diagrammed above. Here are some of the important XML elements to recognize.
  14 +
  15 +* *graphml*: the root element of the GraphML document
  16 + ** *key*: a type description for graph element properties
  17 + ** *graph*: the beginning of the graph representation
  18 + **** *node*: the beginning of a vertex representation
  19 + **** *edge*: the beginning of an edge representation
  20 + ****** *data*: the key/value data associated with a graph element
  21 +
  22 +```xml
  23 +<?xml version="1.0" encoding="UTF-8"?>
  24 +<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
  25 + <key id="weight" for="edge" attr.name="weight" attr.type="float"/>
  26 + <key id="name" for="node" attr.name="name" attr.type="string"/>
  27 + <key id="age" for="node" attr.name="age" attr.type="int"/>
  28 + <key id="lang" for="node" attr.name="lang" attr.type="string"/>
  29 + <graph id="G" edgedefault="directed">
  30 + <node id="1">
  31 + <data key="name">marko</data>
  32 + <data key="age">29</data>
  33 + </node>
  34 + <node id="2">
  35 + <data key="name">vadas</data>
  36 + <data key="age">27</data>
  37 + </node>
  38 + <node id="3">
  39 + <data key="name">lop</data>
  40 + <data key="lang">java</data>
  41 + </node>
  42 + <node id="4">
  43 + <data key="name">josh</data>
  44 + <data key="age">32</data>
  45 + </node>
  46 + <node id="5">
  47 + <data key="name">ripple</data>
  48 + <data key="lang">java</data>
  49 + </node>
  50 + <node id="6">
  51 + <data key="name">peter</data>
  52 + <data key="age">35</data>
  53 + </node>
  54 + <edge id="7" source="1" target="2" label="knows">
  55 + <data key="weight">0.5</data>
  56 + </edge>
  57 + <edge id="8" source="1" target="4" label="knows" >
  58 + <data key="weight">1.0</data>
  59 + </edge>
  60 + <edge id="9" source="1" target="3" label="created">
  61 + <data key="weight">0.4</data>
  62 + </edge>
  63 + <edge id="10" source="4" target="5" label="created">
  64 + <data key="weight">1.0</data>
  65 + </edge>
  66 + <edge id="11" source="4" target="3" label="created">
  67 + <data key="weight">0.4</data>
  68 + </edge>
  69 + <edge id="12" source="6" target="3" label="created">
  70 + <data key="weight">0.2</data>
  71 + </edge>
  72 + </graph>
  73 +</graphml>
  74 +```
  75 +
  76 +Note that line breaks and indentation have been added for clarity. The default output contains no unnecessary whitespace, but @GraphMLWriter@ does include an option to actually insert the whitespace, as well as ordering elements in the output (see below).
  77 +
  78 +h2. Usage
  79 +
  80 +To read GraphML data into a graph, pass the graph into the @GraphMLReader@ constructor, then call @inputGraph@:
  81 +
  82 +```java
  83 +Graph graph = ...
  84 +InputStream in = ...
  85 +
  86 +GraphMLReader.inputGraph(graph, in);
  87 +```
  88 +
  89 +Note that @inputGraph@ is also overloaded with a "buffer size" parameter. Several setter methods are provided for customizing the property keys which @GraphMLReader@ uses to map the GraphML data into the Property Graphs model. If used, these should be called before @inputGraph@, e.g.
  90 +
  91 +```java
  92 +GraphMLReader reader = new GraphMLReader(graph);
  93 +reader.setVertexIdKey("_id");
  94 +reader.setEdgeIdKey("_id");
  95 +reader.setEdgeLabelKey("_label");
  96 +reader.inputGraph(in);
  97 +```
  98 +
  99 +To output a graph in GraphML format, pass the graph into the @GraphMLWriter@ constructor, then call @outputGraph@:
  100 +
  101 +```java
  102 +Graph graph = ...
  103 +OutputStream out = ...
  104 +
  105 +GraphMLWriter.outputGraph(graph, out);
  106 +```
  107 +
  108 +If you have a large graph and you know the key and value type of all vertex and/or edge properties used in your graph, you can speed up @outputGraph@ by first specifying those properties, e.g.
  109 +
  110 +```java
  111 +Map<String, String> vertexKeyTypes = new HashMap<String, String>();
  112 +vertexKeyTypes.put("age", GraphMLTokens.INT);
  113 +vertexKeyTypes.put("lang", GraphMLTokens.STRING);
  114 +vertexKeyTypes.put("name", GraphMLTokens.STRING);
  115 +Map<String, String> edgeKeyTypes = new HashMap<String, String>();
  116 +edgeKeyTypes.put("weight", GraphMLTokens.FLOAT);
  117 +
  118 +GraphMLWriter writer = new GraphMLWriter(graph);
  119 +writer.setVertexKeyTypes(vertexKeyTypes);
  120 +writer.setEdgeKeyTypes(edgeKeyTypes);
  121 +writer.outputGraph(out);
  122 +```
  123 +
  124 +There is an additional @GraphMLWriter@ method, described below, for enabling normalized GraphML output for use with versioning tools.
  125 +
  126 +h2. Normalizing GraphMLWriter output
  127 +
  128 +@GraphMLWriter@ 's default output is sufficient for saving all of the information in a graph in an interoperable format, which can be loaded in @GraphMLReader@ in order to re-create the graph. However, another important use case for @GraphMLWriter@ has to do with versioning and collaborative editing of graphs. If you call the @setNormalize@ method before calling @outputGraph@, @GraphMLWriter@ will apply additional formatting and constraints to the output so as to make it compatible with line-based versioning tools such as "Subversion":http://subversion.apache.org/ and "Git":http://git-scm.com/, e.g.
  129 +
  130 +```java
  131 +GraphMLWriter writer = new GraphMLWriter(graph);
  132 +writer.setNormalize(true);
  133 +writer.outputGraph(out);
  134 +```
  135 +
  136 +The following is an example of normalized GraphML output. Key definitions appear in alphabetical order, as do vertices and edges (according to the string representation of the id) and vertex and edge properties. The XML is indented consistently, with one start and/or end tag per line:
  137 +
  138 +```xml
  139 +<?xml version="1.0" ?>
  140 +<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
  141 + <key id="age" for="node" attr.name="age" attr.type="int"></key>
  142 + <key id="lang" for="node" attr.name="lang" attr.type="string"></key>
  143 + <key id="name" for="node" attr.name="name" attr.type="string"></key>
  144 + <key id="weight" for="edge" attr.name="weight" attr.type="float"></key>
  145 + <graph id="G" edgedefault="directed">
  146 + <node id="1">
  147 + <data key="age">29</data>
  148 + <data key="name">marko</data>
  149 + </node>
  150 + <node id="2">
  151 + <data key="age">27</data>
  152 + <data key="name">vadas</data>
  153 + </node>
  154 + <node id="3">
  155 + <data key="lang">java</data>
  156 + <data key="name">lop</data>
  157 + </node>
  158 + <node id="4">
  159 + <data key="age">32</data>
  160 + <data key="name">josh</data>
  161 + </node>
  162 + <node id="5">
  163 + <data key="lang">java</data>
  164 + <data key="name">ripple</data>
  165 + </node>
  166 + <node id="6">
  167 + <data key="age">35</data>
  168 + <data key="name">peter</data>
  169 + </node>
  170 + <edge id="10" source="4" target="5" label="created">
  171 + <data key="weight">1.0</data>
  172 + </edge>
  173 + <edge id="11" source="4" target="3" label="created">
  174 + <data key="weight">0.4</data>
  175 + </edge>
  176 + <edge id="12" source="6" target="3" label="created">
  177 + <data key="weight">0.2</data>
  178 + </edge>
  179 + <edge id="7" source="1" target="2" label="knows">
  180 + <data key="weight">0.5</data>
  181 + </edge>
  182 + <edge id="8" source="1" target="4" label="knows">
  183 + <data key="weight">1.0</data>
  184 + </edge>
  185 + <edge id="9" source="1" target="3" label="created">
  186 + <data key="weight">0.4</data>
  187 + </edge>
  188 + </graph>
  189 +</graphml>
  190 +```
  191 +
  192 +This format permits line diffs to be used to capture incremental changes to graphs, so that graphs can be conveniently checked in to a version control repository. You can then commit changes to the graph and roll back to previous versions of the graph, just as you would do with a piece of source code. Forking and merging graphs is also possible within certain limits.
  193 +
  194 +Note that normalizing output in @GraphMLWriter@ is a memory-intensive process, so it is best used in connection with small to medium-sized graphs.
310 doc/wiki/GraphSON-Reader-and-Writer-Library.textile
Source Rendered
... ... @@ -0,0 +1,310 @@
  1 +```xml
  2 +<dependency>
  3 + <groupId>com.tinkerpop.blueprints</groupId>
  4 + <artifactId>blueprints-core</artifactId>
  5 + <version>??</version>
  6 +</dependency>
  7 +```
  8 +
  9 +The GraphSON reader and writer package allows an entire graph to be streamed to and from the standard "JSON":http://json.org format which is utilized across the TinkerPop stack. The format comes in two flavors: one that uses explicit data typing within the JSON and one that does not. For most scenarios, standard JSON without data typing should generally be acceptable. Using the more verbose outputting of explicit data types only provides the added value of ensuring that numeric values are converted properly (ie. float versus double).
  10 +
  11 +!https://github.com/tinkerpop/blueprints/raw/master/doc/images/graph-example-1.jpg!
  12 +
  13 +The following example shows the format without explicit data types:
  14 +
  15 +```javascript
  16 +{
  17 + "graph": {
  18 + "vertices": [
  19 + {
  20 + "name": "lop",
  21 + "lang": "java",
  22 + "_id": "3",
  23 + "_type": "vertex"
  24 + },
  25 + {
  26 + "name": "vadas",
  27 + "age": 27,
  28 + "_id": "2",
  29 + "_type": "vertex"
  30 + },
  31 + {
  32 + "name": "marko",
  33 + "age": 29,
  34 + "_id": "1",
  35 + "_type": "vertex"
  36 + },
  37 + {
  38 + "name": "peter",
  39 + "age": 35,
  40 + "_id": "6",
  41 + "_type": "vertex"
  42 + },
  43 + {
  44 + "name": "ripple",
  45 + "lang": "java",
  46 + "_id": "5",
  47 + "_type": "vertex"
  48 + },
  49 + {
  50 + "name": "josh",
  51 + "age": 32,
  52 + "_id": "4",
  53 + "_type": "vertex"
  54 + }
  55 + ],
  56 + "edges": [
  57 + {
  58 + "weight": 1,
  59 + "_id": "10",
  60 + "_type": "edge",
  61 + "_outV": "4",
  62 + "_inV": "5",
  63 + "_label": "created"
  64 + },
  65 + {
  66 + "weight": 0.5,
  67 + "_id": "7",
  68 + "_type": "edge",
  69 + "_outV": "1",
  70 + "_inV": "2",
  71 + "_label": "knows"
  72 + },
  73 + {
  74 + "weight": 0.4000000059604645,
  75 + "_id": "9",
  76 + "_type": "edge",
  77 + "_outV": "1",
  78 + "_inV": "3",
  79 + "_label": "created"
  80 + },
  81 + {
  82 + "weight": 1,
  83 + "_id": "8",
  84 + "_type": "edge",
  85 + "_outV": "1",
  86 + "_inV": "4",
  87 + "_label": "knows"
  88 + },
  89 + {
  90 + "weight": 0.4000000059604645,
  91 + "_id": "11",
  92 + "_type": "edge",
  93 + "_outV": "4",
  94 + "_inV": "3",
  95 + "_label": "created"
  96 + },
  97 + {
  98 + "weight": 0.20000000298023224,
  99 + "_id": "12",
  100 + "_type": "edge",
  101 + "_outV": "6",
  102 + "_inV": "3",
  103 + "_label": "created"
  104 + }
  105 + ]
  106 + }
  107 +}
  108 +```
  109 +
  110 +The following example shows the format with explicit data types:
  111 +
  112 +```javascript
  113 +{
  114 + "embeddedTypes":true,
  115 + "vertices": [
  116 + {
  117 + "name": {
  118 + "type": "string",
  119 + "value": "lop"
  120 + },
  121 + "lang": {
  122 + "type": "string",
  123 + "value": "java"
  124 + },
  125 + "_id": "3",
  126 + "_type": "vertex"
  127 + },
  128 + {
  129 + "name": {
  130 + "type": "string",
  131 + "value": "vadas"
  132 + },
  133 + "age": {
  134 + "type": "integer",
  135 + "value": 27
  136 + },
  137 + "_id": "2",
  138 + "_type": "vertex"
  139 + },
  140 + {
  141 + "name": {
  142 + "type": "string",
  143 + "value": "marko"
  144 + },
  145 + "age": {
  146 + "type": "integer",
  147 + "value": 29
  148 + },
  149 + "_id": "1",
  150 + "_type": "vertex"
  151 + },
  152 + {
  153 + "name": {
  154 + "type": "string",
  155 + "value": "peter"
  156 + },
  157 + "age": {
  158 + "type": "integer",
  159 + "value": 35
  160 + },
  161 + "_id": "6",
  162 + "_type": "vertex"
  163 + },
  164 + {
  165 + "name": {
  166 + "type": "string",
  167 + "value": "ripple"
  168 + },
  169 + "lang": {
  170 + "type": "string",
  171 + "value": "java"
  172 + },
  173 + "_id": "5",
  174 + "_type": "vertex"
  175 + },
  176 + {
  177 + "name": {
  178 + "type": "string",
  179 + "value": "josh"
  180 + },
  181 + "age": {
  182 + "type": "integer",
  183 + "value": 32
  184 + },
  185 + "_id": "4",
  186 + "_type": "vertex"
  187 + }
  188 + ],
  189 + "edges": [
  190 + {
  191 + "weight": {
  192 + "type": "float",
  193 + "value": 1
  194 + },
  195 + "_id": "10",
  196 + "_type": "edge",
  197 + "_outV": "4",
  198 + "_inV": "5",
  199 + "_label": "created"
  200 + },
  201 + {
  202 + "weight": {
  203 + "type": "float",
  204 + "value": 0.5
  205 + },
  206 + "_id": "7",
  207 + "_type": "edge",
  208 + "_outV": "1",
  209 + "_inV": "2",
  210 + "_label": "knows"
  211 + },
  212 + {
  213 + "weight": {
  214 + "type": "float",
  215 + "value": 0.4000000059604645
  216 + },
  217 + "_id": "9",
  218 + "_type": "edge",
  219 + "_outV": "1",
  220 + "_inV": "3",
  221 + "_label": "created"
  222 + },
  223 + {
  224 + "weight": {
  225 + "type": "float",
  226 + "value": 1
  227 + },
  228 + "_id": "8",
  229 + "_type": "edge",
  230 + "_outV": "1",
  231 + "_inV": "4",
  232 + "_label": "knows"
  233 + },
  234 + {
  235 + "weight": {
  236 + "type": "float",
  237 + "value": 0.4000000059604645
  238 + },
  239 + "_id": "11",
  240 + "_type": "edge",
  241 + "_outV": "4",