Database Reference
In-Depth Information
4.
Finally store the complete hierarchy:
graph.commit();
5.
Now to fetch all vertices with Direction.IN (means incoming
edges) and having the label son of using multivertex support, we need
to execute the following query:
//prepare multi vertex query
TitanMultiVertexQuery mq = graph.multiQuery();
mq.direction(Direction.IN).labels("son of");
mq.addVertex((TitanVertex) das);// add root
mq.addVertex((TitanVertex) ram);
mq.addVertex((TitanVertex) bharat);
mq.addVertex((TitanVertex) laxman);
mq.addVertex((TitanVertex) shatrugna);
//execute multi vertex query
Map<TitanVertex, Iterable<TitanVertex>>
dfsResult = mq.vertices();
//iterate through result and print
for (TitanVertex key : dfsResult.keySet())
{
System.out.println("Finding son of" +
key.getProperty("fname"));
Iterable<TitanVertex> sons =
dfsResult.get(key);
Iterator<TitanVertex> sonIter =
sons.iterator();
while (sonIter.hasNext())
{
System.out.println(sonIter.next().getProperty("fname"));
}
}
This way, we can perform faster deep traversal with Titan.
Search WWH ::




Custom Search