docs: def resource_to_rdf(resource, dataset=None, graph=None):
      '''
      Map a Resource domain model to a DCAT/RDF graph
      '''
      graph = graph or Graph(namespace_manager=namespace_manager)
      if dataset and dataset.id:
          id = URIRef(url_for('datasets.show_redirect', dataset=dataset.id,
                              _external=True,
                              _anchor='resource-{0}'.format(resource.id)))
      else:
          id = BNode(resource.id)
      permalink = url_for('datasets.resource', id=resource.id, _external=True)
      r = graph.resource(id)
      r.set(RDF.type, DCAT.Distribution)
      r.set(DCT.identifier, Literal(resource.id))
      r.add(DCT.title, Literal(resource.title))
      r.add(DCT.description, Literal(resource.description))
      r.add(DCAT.downloadURL, URIRef(resource.url))
      r.add(DCAT.accessURL, URIRef(permalink))
      r.add(DCT.issued, Literal(resource.published))
      r.add(DCT.modified, Literal(resource.modified))
      if dataset and dataset.license:
          r.add(DCT.rights, Literal(dataset.license.title))
          if dataset.license.url:
              r.add(DCT.license, URIRef(dataset.license.url))
      if resource.filesize is not None:
          r.add(DCAT.bytesSize, Literal(resource.filesize))
      if resource.mime:
          r.add(DCAT.mediaType, Literal(resource.mime))
      if resource.format:
          r.add(DCT.term('format'), Literal(resource.format))
      if resource.checksum:
          checksum = graph.resource(BNode())
          checksum.set(RDF.type, SPDX.Checksum)
          algorithm = 'checksumAlgorithm_{0}'.format(resource.checksum.type)
          checksum.add(SPDX.algorithm, getattr(SPDX, algorithm))
          checksum.add(SPDX.checksumValue, Literal(resource.checksum.value))
          r.add(SPDX.checksum, checksum)
      return r