# Apoc Path Expand getting relationship properties

**URL:** <https://community.neo4j.com/t/apoc-path-expand-getting-relationship-properties/59228>\
**Category:** Neo4j Graph Platform\
**Tags:** migrated\
**Created:** [October 13, 2022, 9:04am UTC](https://community.neo4j.com/t/apoc-path-expand-getting-relationship-properties/59228 "2022-10-13T09:04:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vence\_andersen1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/vence_andersen1/32/19186_2.png) [@vence\_andersen1](https://community.neo4j.com/u/vence_andersen1)\
**Post date:** [October 13, 2022, 9:04am UTC](https://community.neo4j.com/t/apoc-path-expand-getting-relationship-properties/59228/1 "2022-10-13T09:04:37Z")

</div>

![3X_4_c_4c22619ce8d92d7f2b704707bcb738f07cb838cb.png](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/2/e/2e81ff3671dcc02832bb92089f8a3f269038f70a.png "3X\_4\_c\_4c22619ce8d92d7f2b704707bcb738f07cb838cb.png")

Hi,

I have data like the above image, here my task is when I query the Starting node (here "A1", "B1", and "C1" are the the starting nodes for 3 different paths), I need to get all the path of the nodes. Like when I query "A1" I need to get "A1", "A2", "A3", "A4" and so on till "A7".

Problem is we don't know the number of such connections for a path, as you can see from the image "A" label have 7 conncetions whereas "B" has only 5. Second problem is we don't have the same reltionships between the paths, like relationship between "A1" and "A2" can differ between "A2" and "A3".

Hence I used "apoc.path.expand", this solves all the above problem but it doesn't give the relationships between the nodes. As I want the name of the relationship between nodes also the properties of the relationships.

It would be greatful if someone could help me here. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [October 13, 2022, 9:12pm UTC](https://community.neo4j.com/t/apoc-path-expand-getting-relationship-properties/59228/2 "2022-10-13T21:12:00Z")

</div>

You can get the relationships along a path 'p' with 'relationships(p)' For each relationship 'r' in the collection, you can get its properties with 'properties(r)' and its type with 'type(r).'

One approach to extracting this data is to return it as list of maps for each path. A single map has the properties and type for one relationship along the path. As an example, assume this data:

```auto
create(:Node{id:0})-[:A{value:10, color:'blue'}]->(:Node{id:1})-[:B{value:20, color:'green'}]->(:Node{id:2})

```

Then this query extracts the relationship properties and types.

```auto
match p=(:Node{id:0})-[*]-(:Node{id:2})
return [x in relationships(p) | x{.*, type: type(x)}] as rels

```

![Screen Shot 2022-10-13 at 5.07.52 PM.png](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/8/5/8547930f8df7f87e7dfa0d18e76e483b0b1d9859.png "Screen Shot 2022-10-13 at 5.07.52 PM.png")

BTW- if your structures are simply linked list of nodes, then you can use a query similar to the one above instead of apoc.path.expand. In particular, this should give you the same result, assuming you set the conditions for the root node.

```auto
match p=(:Node{id:0})-[*]->(m)
where not exists((m)-->())
return [x in relationships(p) | x{.*, type: type(x)}] as rels

```
