I want to program this algorithms in Prolog, and first I need to create a matrix from a list of graphs. I've done this before (also with help of some of you, guys), but now I don't know how to store it inside a list of lists (which I suppose it's the best approach in prolog's case). I think I can be able to continue from there (with the triple for loop in each of the algorithms). The logic of the program is not difficult for me, but how to work with data. Sorry for being a bother and thanks in advance!
My matrix generator:
graph(a,b).
graph(a,a).
graph(b,c).
graph(b,d).
graph(c,d).
graph(a,e).
graph(e,f).
matrix :- allnodes(X),printmatrix(X).
node(X) :- graph(X,_).
node(X) :- graph(_,X).
allnodes(Nodes) :- setof(X, node(X), Nodes).
printedge(X,Y) :- graph(Y,X), write('1 ').
printedge(X,Y) :- \+ graph(Y,X), write('0 ').
printmatrix(List):- member(Y, List),nl,member(X, List),printedge(X,Y),fail.