Property paths with None*OneOrMore possible??

11 views
Skip to first unread message

FalFire

unread,
May 23, 2015, 7:53:18 AM5/23/15
to rdfli...@googlegroups.com
Hi, I am trying to match all paths of arbitrary length that end at a given object, so something like g.triples((None, None*OneOrMore, MyObject)). The goal is to do a kind of depth-first-search to find all the vertices that can reach a given vertex, no matter by what kind of edges. Is this possible, or is there a better way to accomplish this?

n...@mayacs.com

unread,
May 27, 2015, 8:12:24 AM5/27/15
to rdfli...@googlegroups.com, edward.b...@gmail.com
Hi,

Sorry, I don't think there's a clever way of making rdflib do the actual search in your case, so you'll probably have to write the loop yourself and just use e.g. g.subjects(object=myobject)

You might be able to do better than that in case you know all the edges that might occur, though. In that case Property Path operators might do the heavy lifting for you, see https://rdflib.readthedocs.org/en/latest/apidocs/rdflib.html#module-rdflib.paths

Cheers,
Niels
Reply all
Reply to author
Forward
0 new messages