code: def find_reachable(rdf, res):
      
  
      starttime = time.time()
  
      # This is almost a non-recursive breadth-first search algorithm, but a set
      # is used as the "open" set instead of a FIFO, and an arbitrary element of
      # the set is searched. This is slightly faster than DFS (using a stack)
      # and much faster than BFS (using a FIFO).
      seen = set()			# used as the "closed" set
      to_search = set([res])  # used as the "open" set
  
      while len(to_search) > 0:
          res = to_search.pop()
          if res in seen:
              continue
          seen.add(res)
          # res as subject
          for p, o in rdf.predicate_objects(res):
              if isinstance(p, URIRef) and p not in seen:
                  to_search.add(p)
              if isinstance(o, URIRef) and o not in seen:
                  to_search.add(o)
          # res as predicate
          for s, o in rdf.subject_objects(res):
              if isinstance(s, URIRef) and s not in seen:
                  to_search.add(s)
              if isinstance(o, URIRef) and o not in seen:
                  to_search.add(o)
          # res as object
          for s, p in rdf.subject_predicates(res):
              if isinstance(s, URIRef) and s not in seen:
                  to_search.add(s)
              if isinstance(p, URIRef) and p not in seen:
                  to_search.add(p)
  
      endtime = time.time()
      logging.debug("find_reachable took %f seconds", (endtime - starttime))
  
      return seen
docs: Return the set of reachable resources starting from the given resource,
      excluding the seen set of resources.
  
      Note that the seen set is modified
      in-place to reflect the ongoing traversal.