GRAPHS - represented with arcs - back to content


		arc(a,b).			arc(b,c).
		arc(a,c).			arc(a,d).
		arc(b,e).			arc(e,f).
		arc(b,f).			arc(f,g).
	
		?- arc(X,Y).  /* finds all the arcs (X,Y) */
		X = a
		Y = b
		X = b
		Y = c
		...
		?- arc(a,X). /* arcs from node a go to node X */
		X = b
		X = c
		X = d
		?- node_out(a,R). /* the list of nodes adjacent to a */
		R = [b,c,d]

		node_out(Nod,R):- findall(X,arc(Nod,X),R).

		?- node_in(c,R)./*  the list of nodes from node  c */
	  	R = [b,a]

		node_in(Nod,R):- findall(X,arc(X,Nod),R).

		?- node_graf(R). /* the list with all the nodes */
		R = [a,b,c,d,e,f,g]

		node_graf(R):- findall(X,(arc(X,_);arc(_,X)),L),sort(L,R).