Querying the shared nodes in a RDF graph

断了今生、忘了曾经 提交于 2019-12-25 03:22:53

问题


I have a graph of RDF data, that is the result of a SPARQL query in rdflib, but this question is valid just on any endpoint too. The graph looks like the picture below.

I want to find a way to query the nodes that are shared between two clusters. Those are basically the nodes that are:

  • Subject to two objects
  • Object to two subjects
  • Object to a subject, and, then subject to another object

I tried with Graph.subjects() and Graph.objects() on rdflib it seems to me that they are only iterable and I have to iterate the whole graph three times, for each of the above scenarios, and it would result in a lot of double counting.

I was wondering if anyone has an idea on how to do this in a better way, perhaps within SPARQL to begin with.

来源:https://stackoverflow.com/questions/53863374/querying-the-shared-nodes-in-a-rdf-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!