Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Pause, resolving how to handle anonymous content

Hyper-edge problem, not sure if there is a better way to solve this, any help will be welcome


Hello everyone, I'm new to Neo4j and I have something in my datamodel that would be perfect to map as an hyper-edge, but Neo4j doesn't seem to support that.

Let me start with an example:

  Interest{name: 'Local News'} -[:INTERESTED]->(Element {name: 'Brazil'})
  Interest{name: 'Mercosul Tech'} -[:INTERESTED]->(Element {name: 'Latin America'}, Element{name: 'Technology'})

  Tag-[]->(Element {name: 'Uruguai'})
  Tag-[]->(Element {name: 'Technology'})
  Tag-[]->(Element {name: 'Technology'})
  Tag-[]->(Element {name: 'Brazil'})
  Tag-[]->(Element {name: 'Technology'})
  Tag-[]->(Element {name: 'Latin America'})
  Tag-[]->(Element {name: 'Uruguai'})

Story#3 will be in the "Local News" section of the newsletter
Story#4 will be in the "Mercosul Tech" section
Stories 1 and 2 will not be in the newsletter

so in my view, the Interest-[INTERESTED]-(Element*) should be an hyper-edge where it can point to one or more Element per node/interest
and that relationship will map to stories that have at least the same elements

Is there an easy or simple way to map and query this in Neo4j?

I have this working in a SQL database today, and it is implemented with a combination of complex queries, I'm trying to port it to a graph database to better model the relationships between these elements, but I have this complex case that doesn't seem to have a direct mapping.


Graph Buddy

yes, you could use something a Singleton. its a pattern used in object oriented programming, you only need to create a unique id for interest node, then you could access to the elements of that interest.

you could reed more about singleton here:


I'm familiar with the singleton pattern, just not sure how that applies to a Neo4J relationship

do you have any idea how I could query starting from the "newsletter instance" stories with tags that match the interested elements as I showed in the sample data?


@urubatan Hyper-edges in Neo4j are implemented as nodes. Check out @Luanne_Misquitta’s NODES 2019 talk where she derives how to model this:

Thank you for the pointer, I'm watching the presentation right now

Node Clone

@urubatan not quite sure a hyperedge is needed yet. Of course I don't have details of your use cases and model but at first glance, a potential model could be

where the data you have in your example would look like

Obvious questions would be whether newsletter sections are common across all newsletters but share different interests- this would require a change in the model, and so on

Hope this helps as a pointer to how you could think of transforming the ER model to a graph model

Hi @Luanne_Misquitta
the thing here is that for example, in "Mercosul Tech" it is one interest "Latin America" + "Technology" and not Latin America or Technology

So the Interest "Mercosul Tech" is associated with both Elements "Latin America" and "Technology" and this combination is an hyper-edge, that should connect only to stories that also have both Elements

I'm watching your presentation now, but I do not think that using a node to represent an Hyper-Edge will solve my problem as it should, since using a node can be used to enforce rules applied to an Hyper-Edge but doesn't have all the functionality but maybe I can write a graph query to match what I need using the "Node Hyper-Graph implementation" 😄

Yes, I don't see a hyperedge either. Rules can be modelled in graphs as well, but it may be overkill for your case, and you might be better off enforcing them via triggers, or other business logic.