0

I want to check for isomorphism across subgraphs in a larger dataset. Is there a way to do this in rdflib without breaking the graph into multiple variables, like in the example from rdflib docs:

g1 = Graph().parse(format='n3', data='''
     @prefix : <http://example.org/ns#> .
     []:rel <http://example.org/a> ;
      :rel <http://example.org/b> ;
      :rel [ :label "A bnode." ] .
 ''')
 g2 = Graph().parse(format='n3', data='''
     @prefix ns: <http://example.org/ns#> .
     []:rel <http://example.org/a> ;
      :rel <http://example.org/b> ;
      :rel [ :label "A bnode." ] .
 ''')
isomorphic(g1, g2)

my graph

[]:rel <http://example.org/a> ;
      :rel <http://example.org/b> ;
      :rel [ :label "A bnode." ] .

[]:rel <http://example.org/a> ;
      :rel <http://example.org/c> ;
      :rel [ :label "A bnode." ] .

[]:rel <http://example.org/a> ;
      :rel <http://example.org/b> ;
      :rel [ :label "A bnode." ] .

Thanks for any help!

Alex
  • 169
  • 1
  • 1
  • 8

1 Answers1

1

Sorry but I don't think there's really a way to do this. The graphs within a Dataset aren't really available on their own - you have to get to them through the graph - so you can't do something like:


# no function get_graph
ds.get_graph(identifier="http://eg.org/a")\
    .isomorphic(ds.get_graph(identifier="http://eg.org/b"))

# or 

# no function get_graph
isomorphic(
    ds.get_graph(identifier="http://eg.org/a"),
    ds.get_graph(identifier="http://eg.org/b"),
)

Nicholas Car
  • 1,164
  • 4
  • 7