🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #595

Re: Duplicate Solutions

#595
From: Sharon J Correll
Date: Thu, 15 Mar 1990 19:41
36 lines
1669 bytes
In article <11500023@hpldola.HP.COM> patch@hpldola.HP.COM (Pat Chkoreff) writes:
>Occasionally I have written a predicate that yields duplicate solutions, and
>I've wondered how to make each solution occur uniquely.  For example, I have
>a multigraph:
>
>	node(X).             % X is a node.
>	edge(E, X, Y).       % E is a directed edge from node X to node Y.
>
>Initially I write:
>
>	joined(X, Y) :-
>		edge(_, X, Y).


How about:

	joined(X,Y) :-
		node(X),
		node(Y),
		an_edge(X,Y).

	an_edge(X,Y) :- edge(_,X,Y), !.

Calling "node" first will instantiate X and Y and then produce exactly one
edge between them.  Two problems with this are:

	1) Both joined(X,Y) and joined(Y,X) could succeed, which
	   probably isn't what you want if they graph is undirected.

	2) All nodes will be examined whether they have edges or not,
	   which isn't terribly efficient. 
-- 
---\  Sharon Correll                                   \---------------
----\  University of Delaware                           \--------------
-----\  Academic Computing and Instructional Technology  \-------------
------\  correll@sun.acs.udel.edu                         \------------
Technical Details
Message-ID: <9149@sun.acs.udel.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!udccvax1!sun.acs.udel.edu!correll
References: <11500023@hpldola.HP.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!udccvax1!sun.acs.udel.edu!correll
From: correll@sun.acs.udel.edu (Sharon J Correll)
Newsgroups: comp.lang.prolog
Subject: Re: Duplicate Solutions
Message-ID: <9149@sun.acs.udel.edu>
Date: 15 Mar 90 19:41:00 GMT
References: <11500023@hpldola.HP.COM>
Reply-To: correll@sun.acs.udel.edu (Sharon J Correll)
Organization: University of Delaware
Lines: 36