Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!ub4b!kulcs!icarus.cs.kuleuven.ac.be From: bimandre@icarus.cs.kuleuven.ac.be (Andre Marien) Newsgroups: comp.lang.prolog Subject: Re: Representing graphs? Message-ID: <4134@n-kulcs.cs.kuleuven.ac.be> Date: 26 Jun 91 07:35:07 GMT References: <6505@goanna.cs.rmit.oz.au> Sender: news@cs.kuleuven.ac.be Organization: Dept. of Computer Science (K.U.Leuven) Lines: 27 Originator: bimandre@icarus > > I would like to know if this is a good way to represent graphs > > or an ugly hack. The idea is to have fast access to the current > > location in the graph and its near neighbours. > > > graph(X) :- > > X = vertice(x,[A,B,C]), > > A = vertice(a,[D,X]), > .... > It's an ugly hack. It is going to get you into big trouble is some > Prologs. It is not an ugly hack. Many people come up with similar ideas; it is a very natural way of describing such a graph. It is an elegant solution if the graph is known and needn't be updated. You can write 'real' Prolog code as in some library, but it is not as simple as this example. If some Prolog doesn't support this, complain to your vendor: there are many non-commercial systems which show it is easy and does not really come in the way of the efficiency of the system (the most important characteristic of Prolog ;-) Andre' Marien bimandre@cs.kuleuven.ac.be