Taxonomy (similar to tags) is defined, in which the names match the post id. Those. we can get a list of posts referenced by this post and a list of posts that link to this post.
How to make a page / report / table like:

On the left in the post id column, at the top of the line is the same. If a post from the left column refers to a post from the top row, then 1, if not, about 0.
How to implement it to get the output table of such a structure?