예제 #1
0
 public function formatGraphResultAsComparableFormat(Result $graph)
 {
     $nodes = [];
     $relationships = [];
     foreach ($graph->getNodes() as $node) {
         $n = $this->formatNodeAsComparableFormat($node);
         $nodes[$n['sha']] = $n;
     }
     foreach ($graph->getRelationships() as $rel) {
         $r = $this->formatRelationshipAsComparableFormat($rel);
         $relationships[$r['sha']] = $r;
     }
     ksort($nodes);
     ksort($relationships);
     $format = ['nodes' => array_values($nodes), 'edges' => array_values($relationships)];
     return $format;
 }
 /**
  * Format spatial api response result
  *
  * @param $response
  * @return ResponseFormat
  */
 private function formatResult($response)
 {
     $responseFormat = new ResponseFormat();
     $result = new Result();
     $i = 0;
     foreach ($response->getBody() as $found) {
         $node = new Node($found['metadata']['id'], $found['metadata']['labels'], $found['data']);
         $result->addNode($node);
     }
     $responseFormat->addResult($result);
     return $responseFormat;
 }