Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-805

Graph#isIsomorphicWith should use semantic equivalence when comparing blank nodes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Jena 2.12.1
    • Jena 2.13.0
    • Jena
    • None

    Description

      It appears that Graph#isIsomorphicWith appears to use syntactic equivalence when comparing blank nodes:

      https://github.com/apache/jena/blob/master/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/GraphMatcher.java#L27

      It should probably use semantic equivalence instead, or, at the very least, respect the RDF 1.1 equivalence of plain literals and xsd:string-typed literals.

      Here is an example that I believe should be considered isomorphic:

          @Test
          public void isomorphismShouldRespectPlainLiteralEquivalence() {
      
              // Without worrying about a blank node, isomorphism works fine:
              Model model1 = ModelFactory.createDefaultModel();
              model1.read(IOUtils.toInputStream("<info:x> <info:y> \"x\""), "", "TTL");
              Model model2 = ModelFactory.createDefaultModel();
              model2.read(IOUtils.toInputStream("<info:x> <info:y> \"x\"^^<http://www.w3.org/2001/XMLSchema#string>"), "", "TTL");
              assertTrue(model1.isIsomorphicWith(model2)); // WORKS
      
              // Now with a blank node:
              Model model3 = ModelFactory.createDefaultModel();
              model3.read(IOUtils.toInputStream("<info:x> <info:y> [ <info:z> \"x\" ]"), "", "TTL");
              Model model4 = ModelFactory.createDefaultModel();
              model4.read(IOUtils.toInputStream("<info:x> <info:y> [ <info:z> \"x\"^^<http://www.w3.org/2001/XMLSchema#string> ]"), "", "TTL");
              assertTrue(model3.isIsomorphicWith(model4)); // BROKEN
          }
      

      Attachments

        Activity

          People

            andy Andy Seaborne
            cbeer Chris Beer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: