I would like to create a Sparql query that contains two counts.
The query should get the 'neighbours of neighbours' of A (A → B → C, where A is the start node), and should report for each C, how many paths there were from A to C, and how many "inlinks" there are to C from anywhere. The result set should be as follow:
C | #C | C_INLINKS
--------------------------
A | 2 | 123
B | 3 | 234
Where #C is the number of paths to C from starting node A.
I can create the counts separately, but I don't know how to combine these:
Count neighbours of neighbours:
select ?c count(?c) as ?countc WHERE {
<http://dbpedia.org/resource/AFC_Ajax> ?p1 ?b.
?b ?p2 ?c.
FILTER (regex(str(?c), '^http://dbpedia.org/resource/'))
}
GROUP BY ?c
ORDER BY DESC(?countc)
LIMIT 100
Count inlinks to neighbours of neigbours
select ?c count(?inlink) as ?inlinks WHERE {
<http://dbpedia.org/resource/AFC_Ajax> ?p1 ?b.
?b ?p2 ?c.
?inlink ?p3 ?c
FILTER (regex(str(?c), '^http://dbpedia.org/resource/'))
}
GROUP BY ?c
ORDER BY DESC(?inlinks)
LIMIT 100
Is it possible to combine these two queries? Thank you!