I'm trying to use the information from edges in a graph. I want to create a list of nodes from the edges in the graph I'm given. For example:
? - graph([edge(1,2),edge(2,3),edge(3,4)],List).
List = [1,2,3,4]
Here's a base case:
graph([edge(X,Y)],[X,Y]).
I have no idea how to do this, without a knowledge base. And why doesn't this just work on its own? Or something like this?
graph([edge(X,Y)], List) :- append(X,Y,List).
I'm very new to Prolog and would appreciate the help.