postgresql – Unroll an entity matching table

I have a table with the following structure:

create pairs of tables (
int block
left_entity int,
right_entity int
);

That table was the result of a process of linking records. One of the characteristics of the table is that left_entity < right_entity.

An example of the data within the table is:

| A | 31 | 36 |
| A | 31 | 34 |
| A | 33 | 39 |
| A | 32 | 33 |
| A | 32 | 39 |
| A | 36 | 37 |
| A | 34 | 37 |
| A | 34 | 36 |
| B | 47 | 49 |

Each pair in this table is considered the same entity.

My goal is to add all the pairs that belong to the same entity in a matrix. So, for the previous example

| A | {31, 34, 36, 37} |
| A | {32, 33, 39} |
| B | {47,49} |

etc

I think the approach should be recursive. CTE or a SIDE UNIT (A similar problem is here), but I can not figure out how to break the loop (since the CTE the solution assumes a parent-child relationship) or how to code the function for the SIDE UNIT (The example assumes that there is only one, but by testing that function with this data you get several rows).
(It seems that the problem is that the data have a structure similar to a graph, instead of the hierarchical structure assumed in the examples).

Any help would be appreciated.