I'm using RDFLIB to build graphs among 3 data-sets (A, B, C) with ntriples.
Goal: graphs contain links among those data-set A->B, B->C and C->A, I want to check consistency of those links by making sure that links outgoing from A refer back to the same entries in A.
Problem: once I iterate over links in the A->B, I wanted to look-up corresponding entries (could be more than one) in the B->C and the same for the C->A, is there a way to look up objects by knowing the subject without iterating over all entries?
The answer is Yes. And you can use to different mechanisms: (a) iterate with a restriction; or (b) issue an SPARQL query.
This solution uses a RDFLib
triples
function over the Graph object. See this reference.A more standard solution using the SPARQL standard.