I'm new to Neo4j, and this is my first time posting. I'm trying to create a monopartite projection from a bipartite graph. I've only got two types of nodes:
- Post nodes: These are all pieces of content, such as tweet, reddit post, news article, etc.,
- Entity nodes: These are the entities associated with the content
My challenge is that I have a handful of different relationships. Some examples:
- (e1:Entity) -[r:TWEETED]->(p:Post)->[r:AT_MENTIONED]->(e2:Entity)
- (e1:Entity) -[r:TWEETED]->(p1:Post)-->[r:QUOTE_TWEETED]->(p2:Post)<-[r:TWEETED]<-(e2:Entity)
- (e1:Entity) -[r:PUBLISHED]->(p:Post)-[r:MENTIONS]->(e2:entity)
What I'm trying to do is
- Change this to a monopartite graph projection that has only the entities but infers a RELATED_TO edge based on all types of relations, not just a single type of relationship and
- Assigns an edge weight based on the number of times two entities co-occur.
In other words, using the examples above:
Example 1:
- Before: (e1:Entity) -[r:TWEETED]->(p:Post)->[r:AT_MENTIONED]->(e2:Entity)
- After: (e1:Entity) -[r:RELATED_TO]-(e2:Entity)
Example 2
- BEFORE: (e1:Entity) -[r:TWEETED]->(p1:Post)-->[r:QUOTE_TWEETED]->(p2:Post)<-[r:TWEETED]<-(e2:Entity)
- AFTER: (e1:Entity) -[r:RELATED_TO]-(e2:Entity)
Example 3
- Before: (e1:Entity) -[r:PUBLISHED]->(p:Post)-[r:MENTIONS]->(e2:entity)
- After: (e1:Entity) -[r:RELATED_TO]-(e2:entity)
I can find examples online that convert only one type of relationship to a monopartite but can't seem to get anything to work for multiple relationship or relationships that have an intervening node of a different type (i.e. two post nodes between an entity node). I've done the graph data science training and couldn't find exactly what I was looking for there either.
Any advice?