A bit of understanding of the SQL DB will get you pretty far here. Say your topic A is file “topic.org”, then you can run a query as follows (copied from How to create a link to a org-roam search?):
(org-roam-db-query
[:select [from] :from links :where (= to $s1)] (expand-file-name org-roam-directory "topic.org"))
That would return you the list of files related to the topic, and you can also then programatically generate a new Org file using the #+INCLUDE
syntax for Org to export all those notes.