 # Combine two relationship from same point

I HAVE ONE RELATIONSHIP
(p)-[s:Rel_A]->(c) and another RELATIONSHIP (p)-[s:Rel_B]->(b)

how will i combine this relationship? AND create one

Hi kanthalepriyanka,

since your first relationship is going to a node "c" and your second is going to a different node "b", how do you want to "combine" the relationships? Do you also want to merge the nodes and then only have one relationship? A single relationship cannot connect three different nodes...

Please specify, which end result you want to achieve.

Regards,
Elena

is it possible to combine node p and then from p create relationship for node c and b?

Yes, of course. Where does your data come from? If you load e.g. all nodes first from a csv and then want to load the relationships, you can "match" for node p and node b, and then for node p and node c and create your relationships and then you will only have one node "p". However, without knowing where this all comes from, it is difficult to advise. Maybe this entry might also help you if you only have one file for nodes and relationships: How to create a relation from two columns in one table?

YES but how will i able to combine relationship
i want p node and want to generate c and b from p in one relationship

Can you draw up an example of what you want? As far as I understand, you want to end up with:

Is that correct or is that wrong?

You can never have three nodes connected by one relationship.

yes i want the same .So what alternate thing we can do ?

As I said before, I would need a little example from you in terms of a graph or a csv to help you further because I am not sure what the problem actually is. Is it a code problem? Is it a loading problem? Is it a modelling problem?

MATCH p=(g:first)-[r:one_to_two]-(g1:second)-[part:two_to_three]-(re:third)-[regu:three_to_four]-(h:fourth)
RETURN p
MATCH p=(re:third)-[regy:three_to_five]-(d:fifth)
NOW what i want is three_to_four and three_to_fifth combined
and for both starting point is three

So, if I understand it correctly, you situation is the following:

And you do not want to have the node "3" twice, but only once. What you can do is:

MATCH (re:third)-[regu]->(h:fourth), (re1:third)-[regy]->(d:fifth)
CREATE (re)-[edgeNew:three_to_five]->(d)
SET edgeNew = regy
DETACH DELETE re1

Then you end up with yes this will work. BUT y does java heap error occures

I do not have a heap error occuring. So, I can't say why it occurs for you...

Reason of heap memory error is -> There is Cartesian Product in the query and you might not have enough memory