Input/output is ascan be lists of listspairs of positive integers, or an adjacency matrix. You can optionally take the domain of the relation (i.e. all unique values in it). The order in which you output the pairs does not matter, and you can assume the input will be nonempty.
Input/output is as lists of lists of positive integers. The order in which you output the pairs does not matter, and you can assume the input will be nonempty.
Input/output is can be lists of pairs of positive integers, or an adjacency matrix. You can optionally take the domain of the relation (i.e. all unique values in it). The order in which you output the pairs does not matter, and you can assume the input will be nonempty.
Next, the relation must be symmetric, so we need to add the inverses of \$(1, 2)\$ and \$(3, 2)\$, resulting in \$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (4, 4), (2, 1), (2, 3)\}\$\$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (2, 1), (2, 3)\}\$.
Finally, the relation must be transitive. Since \$(1, 2)\$ and \$(2, 3)\$ are in the relation, so must be \$(1, 3)\$, and likewise \$(3, 1)\$ must also be in the relation. Adding these results in \$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (4, 4), (2, 1), (2, 3), (1, 3), (3, 1)\}\$\$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (2, 1), (2, 3), (1, 3), (3, 1)\}\$, and this is an equivalence relation.
Next, the relation must be symmetric, so we need to add the inverses of \$(1, 2)\$ and \$(3, 2)\$, resulting in \$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (4, 4), (2, 1), (2, 3)\}\$.
Finally, the relation must be transitive. Since \$(1, 2)\$ and \$(2, 3)\$ are in the relation, so must be \$(1, 3)\$, and likewise \$(3, 1)\$ must also be in the relation. Adding these results in \$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (4, 4), (2, 1), (2, 3), (1, 3), (3, 1)\}\$, and this is an equivalence relation.
Next, the relation must be symmetric, so we need to add the inverses of \$(1, 2)\$ and \$(3, 2)\$, resulting in \$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (2, 1), (2, 3)\}\$.
Finally, the relation must be transitive. Since \$(1, 2)\$ and \$(2, 3)\$ are in the relation, so must be \$(1, 3)\$, and likewise \$(3, 1)\$ must also be in the relation. Adding these results in \$\{(1, 2), (3, 2), (4, 4), (1, 1), (2, 2), (3, 3), (2, 1), (2, 3), (1, 3), (3, 1)\}\$, and this is an equivalence relation.
{(1, 1)} -> {(1, 1)} {(1, 2)} -> {(1, 2), (1, 1), (2, 2), (2, 1)} {(1, 2), (3, 4)} -> {(1, 2), (1, 1), (2, 2), (2, 1), (3, 4), (3, 3), (4, 4), (4, 3)} {(1, 2), (1, 3)} -> {(1, 2), (1, 3), (1, 1), (2, 2), (3, 3), (2, 1), (3, 1), (2, 3), (3, 2)} {(1, 1), (2, 2), (3, 3)} -> {(1, 1), (2, 2), (3, 3)} {(1, 1), (2, 2), (3, 4)} -> {(1, 1), (2, 2), (3, 3), (3, 4), (4, 3)} {(1, 2), (3, 2), (4, 1)} -> {(1, 1), (2, 2), (3, 3), (4, 4), (1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)} {(8, 19), (4, 12), (9, 31), (4, 18)} -> {(8, 8), (8, 19), (19, 8), (19, 19), (4, 4), (4, 12), (4, 18), (12, 4), (12, 12), (12, 18), (18, 4), (18, 12), (18, 18), (9, 9), (9, 31), (31, 9), (31, 31)} {(8, 7), (2, 7), (14, 3), (3, 16)} -> {(2, 2), (2, 7), (2, 8), (7, 2), (7, 7), (7, 8), (8, 2), (8, 7), (8, 8), (3, 3), (3, 14), (3, 16), (14, 3), (14, 14), (14, 16), (16, 3), (16, 14), (16, 16)} {(1, 1), (1, 2)} -> {(1, 1), (1, 2), (2, 1), (2, 2)} {(1, 1)} -> {(1, 1)} {(1, 2)} -> {(1, 2), (1, 1), (2, 2), (2, 1)} {(1, 2), (3, 4)} -> {(1, 2), (1, 1), (2, 2), (2, 1), (3, 4), (3, 3), (4, 4), (4, 3)} {(1, 2), (1, 3)} -> {(1, 2), (1, 3), (1, 1), (2, 2), (3, 3), (2, 1), (3, 1), (2, 3), (3, 2)} {(1, 1), (2, 2), (3, 3)} -> {(1, 1), (2, 2), (3, 3)} {(1, 1), (2, 2), (3, 4)} -> {(1, 1), (2, 2), (3, 3), (3, 4), (4, 3)} {(1, 2), (3, 2), (4, 1)} -> {(1, 1), (2, 2), (3, 3), (4, 4), (1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)} {(8, 19), (4, 12), (9, 31), (4, 18)} -> {(8, 8), (8, 19), (19, 8), (19, 19), (4, 4), (4, 12), (4, 18), (12, 4), (12, 12), (12, 18), (18, 4), (18, 12), (18, 18), (9, 9), (9, 31), (31, 9), (31, 31)} {(8, 7), (2, 7), (14, 3), (3, 16)} -> {(2, 2), (2, 7), (2, 8), (7, 2), (7, 7), (7, 8), (8, 2), (8, 7), (8, 8), (3, 3), (3, 14), (3, 16), (14, 3), (14, 14), (14, 16), (16, 3), (16, 14), (16, 16)} {(1, 1)} -> {(1, 1)} {(1, 2)} -> {(1, 2), (1, 1), (2, 2), (2, 1)} {(1, 2), (3, 4)} -> {(1, 2), (1, 1), (2, 2), (2, 1), (3, 4), (3, 3), (4, 4), (4, 3)} {(1, 2), (1, 3)} -> {(1, 2), (1, 3), (1, 1), (2, 2), (3, 3), (2, 1), (3, 1), (2, 3), (3, 2)} {(1, 1), (2, 2), (3, 3)} -> {(1, 1), (2, 2), (3, 3)} {(1, 1), (2, 2), (3, 4)} -> {(1, 1), (2, 2), (3, 3), (3, 4), (4, 3)} {(1, 2), (3, 2), (4, 1)} -> {(1, 1), (2, 2), (3, 3), (4, 4), (1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)} {(8, 19), (4, 12), (9, 31), (4, 18)} -> {(8, 8), (8, 19), (19, 8), (19, 19), (4, 4), (4, 12), (4, 18), (12, 4), (12, 12), (12, 18), (18, 4), (18, 12), (18, 18), (9, 9), (9, 31), (31, 9), (31, 31)} {(8, 7), (2, 7), (14, 3), (3, 16)} -> {(2, 2), (2, 7), (2, 8), (7, 2), (7, 7), (7, 8), (8, 2), (8, 7), (8, 8), (3, 3), (3, 14), (3, 16), (14, 3), (14, 14), (14, 16), (16, 3), (16, 14), (16, 16)} {(1, 1), (1, 2)} -> {(1, 1), (1, 2), (2, 1), (2, 2)}