Count the number of distinct IRI used in the subject position of triples in the all graphs (or one if graph is pre-bound)
SELECT
(COUNT(DISTINCT ?subject) AS ?subjects)
WHERE {
GRAPH ?graph {
?subject ?predicate ?object .
FILTER(isIRI(?subject))
}
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?graph")
v3("?object")
v2("?predicate")
v1("?subject"):::projected
v5("?subjects")
f0[["isIRI(?subject)"]]
f0 --> v1
v1 -->v2--> v3
bind2[/"count(?subject)"/]
v1 --o bind2
bind2 --as--o v5