Taking huge time to count node which has multiple edge with same specific node?

here is my scenario

Hello

I have specific node label named C . some of this this has multiple edges of same relationship "HAS_DEVICE" with specific node node D. so far I have tried variable length but counting those nodes is taking so much time . here is my query

Match(n:C)-[r:HAS_DEVICE*2..10]-(d:D) return count(n.IDENTITYID),d.DEVICEID as deviceid;

the query is taking huge time . My graph has 10,448,975 nodes and 11,038,864 relationship. I have put identityid as constraints . Is there any wrong of my code or am I something missing here. Kindly help me out

I was expecting output like this
n.Identityid. d.deviceid
3. xyzzy
2. fdfda

Hello @kalyan_b_aninda :slight_smile:

Why have you put relationships hops (*2..10) in your query?

Regards,
Cobra

oh hello @cobra cobra cause I have same relationship has_device more than 2 edges so I have put a range here .

I think there is a misunderstanding, you have to use jumps when you want a path with depth. It's not your case.

You should have a look at this topic to count relations:

Regards,
Cobra

I am checking it :). but the variable length query gave me the actual picture of nodes which are connected with same relationship multiple times with other specific node. Actually I was happy with that but counting these nodes seems cumbersome to me any way checking your solution. I have got reply after a long time from you :)

This query should solve your problem?

MATCH (n:C)-[r:HAS_DEVICE]->(d:D)
RETURN d.DEVICEID AS deviceid, count(n.IDENTITYID) AS total

@cobra I wanted to filter those nodes which have same relationship>=2 with d nodes. I tried this query before post but it shows unfiltered report.
like
deviceid. identityid
ererere. 1

here I one of your solution is similar to me

here in your problem NEXT relationship is directed to multiple times in some specific node from other node . that specific node is my d node and others nodes are my C nodes, I wanted to count C nodes

You have depth in your database?
Do you have?
(A)->(B)->(C)
Or
(A)->(C)
(B)->(C)

Your first post show looks like the second option.

Regards,
Cobra

Ok I am giving you screen shot what I am getting after

match(n:CUSTOMER)-[r:HAS_DEVICE*2..10]-(d:DEVICE) return n,r,d

so here I can limit my range in number. the brown nodes are device and red nodes are customer so I am trying to find out count of customers which are using same device with HAS_DEVICE relationship . you see there is many customer who are using same device. **I am wanting the direct 1 hop customers count from single devices those have >= 2 edges with customer **

Could you create a dummy example I can work on?

@cobra I have managed a solution . I have counted all customer nodes which are connected with each device then export it as csv. After that I ran a python script to filter most connected customer with single device . It worked :). Thank you for your help

1 Like