Graph connections

Description

Connectivity in a graph.

Source: The Art of Prolog

Download

Program source code: graph_connections.pl

Listing

/*
   connected(X,Y) :-
	Node X is connected to node Y in the graph defined by edge/2.
*/	
 
     connected(X,Y) :- connected(X,Y,[X]).
 
     connected(X,X,Visited).
     connected(X,Y,Visited) :- 
		edge(X,N), not member(N,Visited), connected(N,Y,[N|Visited]).
 
%	Program 14.10: Connectivity in a graph

Comments

pl/prolog/pllib/graph_connections.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0