March 16, 2016
graphutils
¶
find_roots()
¶
-
rdfextras.utils.graphutils.
find_roots
(graph, prop, roots=None)[source]¶ Find the roots in some sort of transitive hierarchy.
find_roots(graph, rdflib.RDFS.subClassOf) will return a set of all roots of the sub-class hierarchy
Assumes triple of the form (child, prop, parent), i.e. the direction of RDFS.subClassOf or SKOS.broader
get_tree()
¶
-
rdfextras.utils.graphutils.
get_tree
(graph, root, prop, mapper=<function <lambda>>, sortkey=None, done=None, dir='down')[source]¶ Return a nested list/tuple structure representing the tree built by the transitive property given, starting from the root given
i.e.
- get_tree(graph,
- rdflib.URIRef(“http://xmlns.com/foaf/0.1/Person”), rdflib.RDFS.subClassOf)
will return the structure for the subClassTree below person.
dir=’down’ assumes triple of the form (child, prop, parent), i.e. the direction of RDFS.subClassOf or SKOS.broader Any other dir traverses in the other direction