Neo4j::Driver::Type::Path - Directed sequence of relationships between two nodes
version 0.15
$q = "MATCH p=(a:Person)-[k:KNOWS]->(b:Person) RETURN p"; $path = $driver->session->run($q)->list->[0]->get('p'); ($node_a, $node_b) = $path->nodes; ($relationship_k) = $path->relationships;
A path is a directed sequence of relationships between two nodes. Its direction may be separate from that of the relationships traversed.
It is allowed to be of length 0, meaning there are no relationships in it. In this case, it contains only a single node which is both the start and the end of the path.
Neo4j::Driver::Type::Path implements the following methods.
@nodes = $path->nodes;
Return all nodes of this path.
The start node of this path is the first node in the array this method returns, the end node is the last one.
@nodes = $path->nodes; $start_node = $nodes[0]; $end_node = $nodes[@nodes - 1];
@rels = $path->relationships;
Return all relationships of this path.
The length of a path is defined as the number of relationships.
@rels = $path->relationships; $length = scalar @rels;
Neo4j::Driver::Type::Path implements the following experimental features. These are subject to unannounced modification or removal in future versions. Expect your code to break if you depend upon these features.
$nodes = $path->nodes; # fails $rels = $path->relationships; # fails
The nodes() and relationships() methods die if called in scalar context.
nodes()
relationships()
die
$start_node = $path->[0];
Currently, the paths's sequence may be directly accessed as if the path was a simple arrayref. This is a concession to backwards compatibility, as the data structure only started being blessed as an object in version 0.13.
Relying on this implementation detail is deprecated. Use the accessor methods nodes and relationships instead.
nodes
relationships
$array = $path->path;
Return the path as an array reference, alternating between nodes and relationships in path sequence order. This is similar to REST::Neo4p::Path's as_simple() method.
as_simple()
When paths are returned via HTTP, the objects accessible via nodes() and relationships() lack meta data for their labels and types. This is due to an issue in the Neo4j server.
Neo4j::Driver
Equivalent documentation for the official Neo4j drivers: Path (Java)
Arne Johannessen <ajnn@cpan.org>
This software is Copyright (c) 2016-2020 by Arne Johannessen.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Neo4j::Driver, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Neo4j::Driver
CPAN shell
perl -MCPAN -e shell install Neo4j::Driver
For more information on module installation, please visit the detailed CPAN module installation guide.