Database Reference
In-Depth Information
Writing Data to a Graph
After instantiating an instance of a graph, let's explore writing vertices and incident
edges into a graph. We will be discussing the same Twitter example and will build a
graph-based implementation for the user, its tweets, and followers.
Figure 7-19 shows a representation of a problem we will be implementing using the
TitanGraph API.
Figure 7-19 . User vivek is following apress_team and tweets about his Cassandra book on Twitter
1.
Let's add a vertex to the graph:
Vertex vivs = graph.addVertex(null);
vivs.setProperty("fname", "vivek");
vivs.setProperty("lname", "mishra");
vivs.setProperty("twitter_tag", "mevivs");
Here, Vertex is an API referred from Blueprints. The following are
import statements for the preceding code snippet:
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Vertex;
You can assume a vertex as Java POJO and its properties as field
variables.
 
 
Search WWH ::




Custom Search