Juan I've not done it in Jena but I have done it in dotNetRDF
The general approach is to treat triples with blank nodes separately from those without. For triples with no blank nodes you can simply do contains() checks across the two models to find the differences. For those with blank nodes divide them up into sub-graphs I.e. - Start from an arbitrary triple that has a blank node create a new sub-graph - Find all other blank node containing triples that also contain that blank node and add them to that sub-graph - Iterate until no further triples can be added to the current sub-graph being constructed - If there are still triples with blank nodes build continue to build sub-graph(s) This will give you two sets of sub-graphs for the two models, you can then use isIsomorphicWith() to check whether each sub-graph has an equivalent sub-graph in the other model. You can use the size of the sub-graphs to reduce the size of the solution space to check. Bear in mind that you might end up with sub-graph(s) that have multiple possible isomorphic sub-graphs in the other model (and vice versa) so you will need to take that into account when determining the differences. Hope this helps, Rob On 23/09/2015 16:19, "Juan Sequeda" <[email protected]> wrote: >On Wed, Sep 23, 2015 at 5:12 PM, Chris Dollin ><[email protected]> >wrote: > >> On 09/23/2015 04:06 PM, Juan Sequeda wrote: >> >> I was looking into the difference and isIsomorphicWith method of a Jena >>> Model when there are Blank Nodes. >>> >>> The isIsomorphicWith returns the expected results when two RDF graphs >>>with >>> blank nodes are effectively isomorphic. However, I would expect that if >>> two >>> RDF graphs are isomorphic, then there shouldn't be a difference. But >>>when >>> blank nodes are in the graph, then all the triples that have blank >>>nodes >>> are considered to be different. I assume then that the difference >>>method >>> has been implemented in a way that it does take in account the labels >>>of >>> the blank nodes (when the definition of isIsomorphicWith states the >>> opposite). Is my assumption correct? >>> >> >> Yes. Difference just compares nodes for equality; it doesn't treat >> blank nodes as variables. Two blank nodes with different labels are >> different blank nodes. >> >> Is there a way in Jena where difference follows the same definition of >>> isIsomorphicWith and ignores the labels on blank nodes. >>> >> >> Not as far as I'm aware. > > >I guess I would have to implement this on my own. > >I'm sure somebody has tried to do this before :) > > >> >> >> Chris >>
