/** * find path between to nodes * * @todo Add handling for relationships * @todo Add algorithm parameter * * @example curl -H Accept:application/json -H Content-Type:application/json -d '{ "to": "http://localhost:9999/node/3" }' -X POST http://localhost:9999/node/1/pathfinder * * @throws \Neo4j\Exception\HttpException * @throws \Neo4j\Exception\NotFoundException * * @param Node $toNode * @param int|null $maxDepth * @param Relationships|null $relationships * @param string|null $singlePath * * @return array */ public function findPaths(Node $toNode, $maxDepth = null, Relationships $relationships = null, $singlePath = null) { $this->_pathFinderData['to'] = $this->_db->getBaseUri() . 'node' . '/' . $toNode->getId(); if ($maxDepth) { $this->_pathFinderData['max depth'] = $maxDepth; } if ($singlePath) { $this->_pathFinderData['single path'] = $singlePath; } if ($relationships) { $this->_pathFinderData['relationships'] = $relationships->get(); } list($response, $http_code) = Request::post($this->getUri() . '/pathfinder', $this->_pathFinderData); if ($http_code == 404) { throw new \Neo4j\Exception\NotFoundException(); } if ($http_code != 200) { throw new \Neo4j\Exception\HttpException("http code: " . $http_code . ", response: " . print_r($response, true)); } $paths = array(); foreach ($response as $result) { $paths[] = Path::inflateFromResponse($this->_db, $result); } if (empty($paths)) { throw new \Neo4j\Exception\NotFoundException(); } return $paths; }