# Graph embedding for smiliarity measurements of hierarchical graphs

**URL:** <https://community.neo4j.com/t/graph-embedding-for-smiliarity-measurements-of-hierarchical-graphs/39635>\
**Category:** Cypher\
**Tags:** embedding, cypher, path, data-science\
**Created:** [June 10, 2021, 9:11am UTC](https://community.neo4j.com/t/graph-embedding-for-smiliarity-measurements-of-hierarchical-graphs/39635 "2021-06-10T09:11:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikthomaskaminski](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/erikthomaskaminski/32/18644_2.png) [@erikthomaskaminski](https://community.neo4j.com/u/erikthomaskaminski)\
**Post date:** [June 10, 2021, 9:11am UTC](https://community.neo4j.com/t/graph-embedding-for-smiliarity-measurements-of-hierarchical-graphs/39635/1 "2021-06-10T09:11:45Z")

</div>

Hello beautitful Neo4j community.

I want to adress you as I am trying to solve an issue for my thesis and I am struggling with the implementation.

Lets say I have two graphs, which represent the structure of two variations of the same product that I want to compare for similarity. As these variations are inside of a huge manufacturing traceability database which contains thousends of these product variations structures, process structures and order structures, I firstly split the content in a projected graph with only the product related components so I can easily traverse it to get a product structure like shown bellow:

first for the assemblyID 'W0128'

 ![Captura de pantalla 2021-06-10 a las 10.55.32](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/1/e/1e1b449dd83f0788554370dc981f3962dfd15805.jpeg)

then for the assemblyID 'W0120'

 ![Captura de pantalla 2021-06-10 a las 10.56.44](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/1/5/15f32429bb7be4b41b26efd141cb7ae594c761d0.jpeg)

Now my intention is to embbed these two product structures into two different vectors where I can then run the similarity algorithms and compare these two. For me to embbed a product structure (like represented above) I need to create a projected graph for each as the library requests so.

My question would be:

1. how can i create a subgraph in neo4j after having traversed another subgraph within a query?

I appreciate a lot your support as I am not coming foward.

Thankyou so much and I wish you a nice day 🙂

Erik Thomas

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [June 24, 2021, 12:40am UTC](https://community.neo4j.com/t/graph-embedding-for-smiliarity-measurements-of-hierarchical-graphs/39635/2 "2021-06-24T00:40:40Z")

</div>

You could use subgraph filtering (e.g. based on cluster-id or product id) to split your in-memory graph from GDS into individual graphs that you then compute embeddings on each of them

Available from gds 1.6

[https://neo4j.com/docs/graph-data-science/1.6-preview/management-ops/graph-catalog-ops/#catalog-graph-create-subgraph](https://neo4j.com/docs/graph-data-science/1.6-preview/management-ops/graph-catalog-ops/#catalog-graph-create-subgraph)
