I'm pretty new to neo4j and actually this is my first stackoverflow question so please be gentle :)
Is there an elegant solution how to group subgraphs into new nodes and use these nodes as first class citizen while still be able to expand these nodes into their former subgraph structure?
Background: My goal is to build a kind of type system over the graph:
I have certain subgraphs in my neo4j graph-database that all satisfy a certain common pattern(combination of certain tags, properties and edges). Let's name these {s1, s2, s3, s4}.
Now I want to group these subgraphs with that certain pattern (let's name it p1) into new nodes as instances of a new type t1. I want then be able to query for nodes of type t1. The edges of these new nodes would then be the former edges connecting the subgraph to the rest of the graph. Still I want to be able to expand those nodes into their former subgraph structure. Also I want to be able to group a different subgraph s5 (maybe even containing some parts of s1) that forms pattern p2 into a new node of types t2.
Then it would also be nice to group t1 and t2 into a type t3 and so on to build a type hierarchy of abstract data types.
My solution so far would be to create a "container node" that has specified edges to my subgraph-nodes and then connect these container nodes in the same fashion to "type nodes". And then connect type nodes to a type hierarchy. But it seems to me quite the hacky way to do this. Maybe there is a better approach.
Is there a built-in solution or an elegant way to achieve this functionality (preferably in neo4j but also in other graph-databases)?