diff --git a/README.md b/README.md
index 0d3ea21..c2d3332 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,7 @@ package com.redislabs.redisgraph;
import com.redislabs.redisgraph.graph_entities.Edge;
import com.redislabs.redisgraph.graph_entities.Node;
+import com.redislabs.redisgraph.graph_entities.Path;
import com.redislabs.redisgraph.impl.api.RedisGraph;
import java.util.List;
@@ -115,6 +116,15 @@ public class RedisGraphExample {
System.out.println(record.toString());
}
+ resultSet = graph.query("social", "MATCH p = (:person)-[:knows]->(:person) RETURN p");
+ while(resultSet.hasNext()) {
+ Record record = resultSet.next();
+ Path p = record.getValue("p");
+
+ // More path API at Javadoc.
+ System.out.println(p.nodeCount());
+ }
+
// delete graph
graph.deleteGraph("social");
diff --git a/pom.xml b/pom.xml
index 2b2c133..c137ec9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,25 @@
1.6.6
test
-
+
+ org.junit.jupiter
+ junit-jupiter
+ RELEASE
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ RELEASE
+ test
+
+
+ nl.jqno.equalsverifier
+ equalsverifier
+ 3.1.10
+ test
+
+
8
8
diff --git a/src/main/java/com/redislabs/redisgraph/graph_entities/Path.java b/src/main/java/com/redislabs/redisgraph/graph_entities/Path.java
new file mode 100644
index 0000000..fa86484
--- /dev/null
+++ b/src/main/java/com/redislabs/redisgraph/graph_entities/Path.java
@@ -0,0 +1,118 @@
+package com.redislabs.redisgraph.graph_entities;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * This class represents a path in the graph.
+ */
+public final class Path {
+
+ private final List nodes;
+ private final List edges;
+
+
+ /**
+ * Parametrized constructor
+ * @param nodes - List of nodes.
+ * @param edges - List of edges.
+ */
+ public Path(List nodes, List edges) {
+ this.nodes = nodes;
+ this.edges = edges;
+ }
+
+ /**
+ * Returns the nodes of the path.
+ * @return List of nodes.
+ */
+ public List getNodes() {
+ return nodes;
+ }
+
+ /**
+ * Returns the edges of the path.
+ * @return List of edges.
+ */
+ public List getEdges() {
+ return edges;
+ }
+
+ /**
+ * Returns the length of the path - number of edges.
+ * @return Number of edges.
+ */
+ public int length() {
+ return edges.size();
+ }
+
+ /**
+ * Return the number of nodes in the path.
+ * @return Number of nodes.
+ */
+ public int nodeCount(){
+ return nodes.size();
+ }
+
+ /**
+ * Returns the first node in the path.
+ * @return First nodes in the path.
+ * @throws IndexOutOfBoundsException if the path is empty.
+ */
+ public Node firstNode(){
+ return nodes.get(0);
+ }
+
+ /**
+ * Returns the last node in the path.
+ * @return Last nodes in the path.
+ * @throws IndexOutOfBoundsException if the path is empty.
+ */
+ public Node lastNode(){
+ return nodes.get(nodes.size() - 1);
+ }
+
+ /**
+ * Returns a node with specified index in the path.
+ * @return Node.
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * ({@code index < 0 || index >= nodesCount()})
+ */
+ public Node getNode(int index){
+ return nodes.get(index);
+ }
+
+ /**
+ * Returns an edge with specified index in the path.
+ * @return Edge.
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * ({@code index < 0 || index >= length()})
+ */
+ public Edge getEdge(int index){
+ return edges.get(index);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Path path = (Path) o;
+ return Objects.equals(nodes, path.nodes) &&
+ Objects.equals(edges, path.edges);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nodes, edges);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder("Path{");
+ sb.append("nodes=").append(nodes);
+ sb.append(", edges=").append(edges);
+ sb.append('}');
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java b/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java
index fdcdf66..442573b 100644
--- a/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java
+++ b/src/main/java/com/redislabs/redisgraph/impl/resultset/ResultSetImpl.java
@@ -6,10 +6,7 @@
import com.redislabs.redisgraph.ResultSet;
import com.redislabs.redisgraph.Statistics;
import com.redislabs.redisgraph.exceptions.JRedisGraphRunTimeException;
-import com.redislabs.redisgraph.graph_entities.Edge;
-import com.redislabs.redisgraph.graph_entities.GraphEntity;
-import com.redislabs.redisgraph.graph_entities.Node;
-import com.redislabs.redisgraph.graph_entities.Property;
+import com.redislabs.redisgraph.graph_entities.*;
import com.redislabs.redisgraph.impl.graph_cache.GraphCache;
import redis.clients.jedis.util.SafeEncoder;
import redis.clients.jedis.exceptions.JedisDataException;
@@ -245,12 +242,21 @@ private Object deserializeScalar(List