I am not sure that everything is working as expected, but this could be something to get you started (sorry for not using the set-up of your MWE):
\documentclass[border=1mm]{standalone}
\usepackage{tikz, pgfplots}
\pgfplotstableread{
x y
0 -1
1 -1
-2 3
5 -5
-4 4
4 1
4 2
0 -5
0 5
2 0
}\nodesdefs
\pgfplotstableread[header=false]{
0 0 1 1 0 1 0 0 1 0
1 0 1 0 1 0 0 1 0 1
0 0 0 0 1 1 0 0 0 0
1 1 1 0 1 1 0 0 1 1
1 0 0 0 0 0 0 1 0 0
1 1 0 0 0 0 1 1 1 1
0 1 1 1 0 0 0 1 1 0
0 1 1 0 1 0 0 0 1 0
1 1 1 1 1 1 1 1 0 1
0 0 0 0 1 1 0 0 1 0
}\edgesdefs
\begin{document}
\begin{tikzpicture}
\begin{axis}
% Count the number of rows of the nodes matrix
% (needed for adding coordinates)
\pgfplotstablegetrowsof{\nodesdefs}
\pgfmathtruncatemacro\NodeRows{\pgfplotsretval-1}
% In a first cycle plot all the nodes from the list and
% attach a coordinate to it for later reference
\addplot[only marks] table[x=x, y=y] {\nodesdefs}
\foreach \i in {0,...,\NodeRows} {
coordinate [pos=\i/\NodeRows] (a\i)
};
\end{axis}
% Count the number of rows and columns of the edges matrix
\pgfplotstablegetcolsof{\edgesdefs}
\pgfmathtruncatemacro\EdgeCols{\pgfplotsretval-1}
\pgfplotstablegetrowsof{\edgesdefs}
\pgfmathtruncatemacro\EdgeRows{\pgfplotsretval-1}
% For each item in the edges matrix, check whether it is 1 or 0;
% if it is 1, draw a line between the relevant coordinates
\foreach \x in {0,...,\EdgeRows}{
\foreach \y in {0,...,\EdgeCols}{
\pgfplotstablegetelem{\x}{[index]\y}\of{\edgesdefs}
\ifnum\pgfplotsretval=1
\draw (a\x) -- (a\y);
\fi
}
}
\end{tikzpicture}
\end{document}

Testing the result only for the first row of the edges matrix:
\pgfplotstableread[header=false]{
0 0 1 1 0 1 0 0 1 0
}\edgesdefs

Looks correct to me: Node 1 (0,-1)
connects to nodes 3, 4, 6 and 9 with coordinates (-2,3)
, (5,-5)
, (4,1)
and (0,5)
respectively.
A short (or maybe not so short) note regarding coordinate [pos=\i/\NodeRows] (a\i)
which may be difficult to understand: Imagine a plot that is drawn by PGF/TikZ as one long line. This line may be bent or have edges, but it still is one line that goes through the several coordinates defined by the list of coordinates. Now, let's say you have 10 coordinates defined, then you can essentially go to the point on this line where the first coordinate sits with the statement [pos=0.1]
, because 1 divided by 10 is 0.1. This way, I used the pos
option to go along the plotted path and attach the coordinates at the correct positions.
Edit:
Another way without the need to give an adjacency table could be as follows. Instead of the adjacency table, you just give a list of nodes to connect (for example 3,4,6,8
) for the row that represents the relevant node (that is, the first row would represent the first node).
\documentclass[border=1mm]{standalone}
\usepackage{tikz, pgfplots}
\pgfplotstableread{
x y
0 -1
1 -1
-2 3
5 -5
-4 4
4 1
4 2
0 -5
0 5
2 0
}\nodesdefs
\pgfplotstableread[header=false]{
3,4,6,8
3,5
}\edgesdefs
\begin{document}
\begin{tikzpicture}
\begin{axis}
% Count the number of rows of the nodes matrix
% (needed for adding coordinates)
\pgfplotstablegetrowsof{\nodesdefs}
\pgfmathtruncatemacro\NodeRows{\pgfplotsretval-1}
% In a first cycle plot all the nodes from the list and
% attach a coordinate to it for later reference
\addplot[only marks] table[x=x, y=y] {\nodesdefs}
\foreach \i in {0,...,\NodeRows} {
coordinate [pos=\i/\NodeRows] (a\i)
};
\end{axis}
% Count the number of rows of the edges matrix
\pgfplotstablegetrowsof{\edgesdefs}
\pgfmathtruncatemacro\EdgeRows{\pgfplotsretval-1}
% For each item in the edges matrix, check whether it is 1 or 0;
% if it is 1, draw a line between the relevant coordinates
\foreach \x in {0,...,\EdgeRows}{
\pgfplotstablegetelem{\x}{[index]0}\of{\edgesdefs}
\foreach \y in \pgfplotsretval{
\draw (a\x) -- (a\y);
}
}
\end{tikzpicture}
\end{document}
