Here is an example of use for .Net:
First, remember to include in your code the algorithms package by adding:
using com.sparsity.dex.algorithms;
We assume here, that you already have a created db with nodes and edges included.
System.Console.WriteLine("Traversal BFS");
// Create a new BFS traversal from the node "startingNode"
TraversalBFS bfs = new TraversalBFS(sess, startingNode);
// Allow the use of all the node types
bfs.AddAllNodeTypes();
// Allow the use of all the edge types but only in outgoing direction
bfs.AddAllEdgeTypes(EdgesDirection.Outgoing);
// Limit the depth to 3 hops from the starting node
bfs.SetMaximumHops(3);
// Get the nodes
while (bfs.HasNext())
{
long nodeid = bfs.Next();
int depth = bfs.GetCurrentDepth();
System.Console.WriteLine("Node "+nodeid+" at depth "+depth+".");
}
// Close the traversal
bfs.Close();
If otherwise you want to traverse the graph in depth (DFS: http://en.wikipedia.org/wiki/Depth-first_search):
System.Console.WriteLine("Traversal DFS");
// Create a new DFS traversal from the node "startingNode"
TraversalDFS dfs = new TraversalDFS(sess, startingNode);
// Allow the use of all the node types
dfs.AddAllNodeTypes();
// Allow the use of all the edge types but only in outgoing direction
dfs.AddAllEdgeTypes(EdgesDirection.Outgoing);
// Limit the depth to 3 hops from the starting node
// dfs.SetMaximumHops(3);
// Get the nodes
while (dfs.HasNext())
{
long nodeid = dfs.Next();
int depth = dfs.GetCurrentDepth();
System.Console.WriteLine("Node "+nodeid+" at depth "+depth+".");
}
// Close the traversal
dfs.Close();