Neoxygen\NeoClient\Formatter\Result::getNodes PHP Method

getNodes() public method

Returns all nodes if called without arguments. Returns all nodes with the given labels if called with an array of labels. Otherwise, acts identically as {@link Result::getNodesByLabels()}.
public getNodes ( string | string[] | null $label = null, boolean $labelizedKeys = false ) : Neoxygen\NeoClient\Formatter\Node[]
$label string | string[] | null
$labelizedKeys boolean
return Neoxygen\NeoClient\Formatter\Node[]
    public function getNodes($label = null, $labelizedKeys = false)
    {
        if (null !== $label) {
            if (is_array($label)) {
                $nodes = [];
                foreach ($label as $lbl) {
                    $nodes[$lbl] = $this->getNodesByLabel($lbl);
                }
                return $nodes;
            }
            return $this->getNodesByLabel($label, $labelizedKeys);
        }
        return $this->nodes;
    }

Usage Example

コード例 #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;
 }