cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Want to define a hyper-edge

neo4joe
Node Clone

A hyper-edge is a graph construct that is a relationship with 3 or more endpoints. Neo4j does not have these, but I would like to fake one in Neo4j.
The idea would follow this example of modeling a contract:

  1. Create a node label called "ContractHyperEdge"
  2. Create two nodes with the label "Person", and one with the label "Contract".
  3. Create a trigger for the ContractHyperedge label that says whenever any node with that label is created or modified, do not save changes unless it is connected to two Contract node and one Person nodes.
    It's tricky because even if you manage to enforce the 2-Person 1-Contract rule on the ContractHyperedge itself, it would be hard to enforce that rule on the connected contract or person nodes. If someone were to delete one of the persons from the database, then the hyper-edge should either prevent that from happening or terminate itself.

Can anyone recommend an approach, even different from mine?

1 ACCEPTED SOLUTION

neo4joe
Node Clone

I no longer believe that a hyper-edge is necessary for this. The contract can take the place of the hyper-edge above and connect directly to the two Person nodes. I will close this question and post a better defined question.

View solution in original post

5 REPLIES 5

neo4joe
Node Clone

Okay, an addional thought came to me over the weekend. Every member (node) connected to a hyper-edge node could share a label that marks it as a member of that relationship. Then a trigger can be defined for every member, so that any changes on any of the hyper-edge members would trigger a lookup of the ContractHyperEdge itself, and cause it to do the contract enforcement check. If it fails, the transaction fails, whether it was invoked on the ContractHyperEdge or on any of the member nodes. The label they all share would not be needed for indexed lookups; the only reason for giving them the same label is so that a query can quickly identify the 'rest' of the contract members, using only traversal--all one hop away from the ContractHyperEdge.

And the label--let's say it's named "PhotoShareContract"--can be used broadly across the database on many different contracts without conflict. Even if one person has multiple contracts of the same name with different people, the 3 relationships connecting them can hold a property shared only by those 3...perhaps a combination of date and contract participant ids.

neo4joe
Node Clone

I no longer believe that a hyper-edge is necessary for this. The contract can take the place of the hyper-edge above and connect directly to the two Person nodes. I will close this question and post a better defined question.

clem
Graph Steward

Also see:

I think HyperEdges would require the Neo4J internals to be radically altered, which is not desired.

Well articulated article. Thanks clem!

Hello @neo4joe

I'm working with hyper-edges (simplicial complex) and Neo4j and we model it as a bipartite graph.

Regards,
Cobra