com.datastax.driver.dse.graph

## Interface Path

• All Superinterfaces:
Iterable<GraphNode>

public interface Path
extends Iterable<GraphNode>
A walk through a graph as defined by a traversal.

Clients typically obtain instances of this class by calling GraphNode.asPath(), for example:

     GraphNode n = dseSession.executeGraph("g.V().hasLabel('some_vertex').outE().inV().path()").one();
Path path = n.asPath();

• ### Method Summary

All Methods
Modifier and Type Method and Description
List<Set<String>> getLabels()
Returns the sets of labels of the steps traversed by this path, or an empty list, if this path is empty.
GraphNode getObject(int index)
Returns the object associated with the given step of this path.
GraphNode getObject(String label)
Returns the first object with the given label in this path.
List<GraphNode> getObjects()
Returns the objects traversed by this path, or an empty list, if this path is empty.
List<GraphNode> getObjects(String label)
Returns the objects with the given label in this path.
boolean hasLabel(String label)
Returns whether this path has at least one step with the given label.
int size()
Returns the size of this path, that is, the number of steps this path traversed.
• ### Methods inherited from interface java.lang.Iterable

forEach, iterator, spliterator
• ### Method Detail

• #### getLabels

List<Set<String>> getLabels()
Returns the sets of labels of the steps traversed by this path, or an empty list, if this path is empty.

The returned list is immutable.

Returns:
the sets of labels of the steps traversed by this path.
• #### getObjects

List<GraphNode> getObjects()
Returns the objects traversed by this path, or an empty list, if this path is empty.

The returned list is immutable.

Returns:
the objects traversed by this path.
• #### size

int size()
Returns the size of this path, that is, the number of steps this path traversed.
Returns:
the size of this path.
• #### getObject

GraphNode getObject(int index)
Returns the object associated with the given step of this path.

The step index is zero-based, i.e. the first step has index 0.

If the index is out of bounds, this method returns null; no exception will be thrown.

Parameters:
index - the zero-based step index to find the object for.
Returns:
the object associated with the given step index.
• #### getObject

GraphNode getObject(String label)
Returns the first object with the given label in this path.

If the label is associated with more then one step, then this method returns the object at the first step with that label.

If the label does not exist in this path, this method returns null.

Parameters:
label - the label to find an object for.
Returns:
the first object with the given label.
• #### getObjects

List<GraphNode> getObjects(String label)
Returns the objects with the given label in this path.

If the label is unique, the returned list will contain only one element.

If the label is associated with more then one step, then the list will contain as many elements as the number of times the label appears in this path's steps, in order.

If the label does not exist in this path, an empty list is returned.

The returned list is immutable.

Parameters:
label - the label to find objects for.
Returns:
the objects with the given label.
• #### hasLabel

boolean hasLabel(String label)
Returns whether this path has at least one step with the given label.
Parameters:
label - the label to search.
Returns:
true if this path has at least one step with the given label, false otherwise.