I have a collection of RDF triples like following.
id#7289587 ex:getInfectedBy id#7748320
id#7694711 ex:getInfectedBy id#7748320
id#7748322 ex:getInfectedBy id#7748320
id#7748887 ex:getInfectedBy id#7748320
id#7746679 ex:getInfectedBy id#7748510
id#6434108 ex:getInfectedBy id#7748510
id#7458397 ex:getInfectedBy id#7748510
My goal is to count star subgraph pattern of the various node lengths (4,5,6,...,20). For example, I have written following query to find a star subgraph pattern of node length 4 (?s1 ?s2 ?s3 ?o).
SELECT ?o count(distinct ?o)
WHERE
{
?s1 ?p ?o.
?s2 ?p ?o.
?s3 ?p ?o.FILTER((?s1!=?s2) && (?s1!=?s3) && (?s2!=?s3))
} group by ?o
The above mentioned query count star pattern length of node 4 for both nodes id#7748320
and id#7748510
. However it suppose to give me the result for only node id#7748510
. If I modify the query with 5 node star pattern then nodeid#7748320
shows up there as well. Could you please help me to fix it?
Is it possible to count star subgraph pattern of various node length (4,5,6,...,20) with one query? Please let me know. I appreciate your help.