[api] Sharing of algorithm does not consider attached libraries

As of today, algorithm sharing only considers the used data formats, but not used libraries. We should change in such a way that it does.

Furthermore, libraries can also use libraries, so sharing a library should also affect libraries that are needed by that library.