One common challenge when traversing a graph is to obtain the neighbors for a certain node. In previous versions of DEX it required a two-step operation; first obtaining the edges for the node and then its neighbors.

`Objects neighbors = new Objects(graphPool);`

Objects e = graph.explode(node, edgeTypeId, Graph.EDGES_OUT); //With “ explode” we obtain the outing edges of node

Objects.Iterator it = e.iterator(); //With the iterator we obtain all the neighbors for all the edges exploded

while (it.hasNext()) {

long eid = it.next();

long neighbor = graph.getEdgePeer(eid, node);

neighbors.add(neighbor);

}

it.close();

In DEX 3.0 if the user creates a specific index for this operation, the retrieval of neighbors is straight forward and therefore executed faster making it in just one step. The user when creating the edge must specify if neighbors must be materialized or not:

public int newEdgeType(java.lang.String name,boolean directed, boolean neighbors) //Where neighbors is “ true” if they must be materialized and “false” otherwise

And then for the retrieval operation only the method `public Objects neighbors(long oid, int type, short direction)`

has to be used.

Hope you find this useful, stay tuned for more features to follow. Also do not forget to check graph algorithms and regular expressions posts.