🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #2370

Re: Representing graphs?

#2370
From: Richard A. O'Keefe
Date: Tue, 25 Jun 1991 11:48
25 lines
1607 bytes
In article <ARI.HUTTUNEN.91Jun23021130@wonderwoman.hut.fi>, Ari.Huttunen@hut.fi (Ari Juhani Huttunen) writes:
> 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.  The file GRAPHS.PL in the DEC-10 Prolog library provides
several representations for graphs, including
	list of edges					-- sorted!
	list of node-(list of neighbours)		-- sorted!
These representations appear to be adequate for a great many tasks,
allowing the graph algorithms I was interested in to be coded in
Prolog with the same asymptotic cost as in Pascal or C (admittedly
with higher constant factors).  Another representation would be the
adjacency matrix, represented as a quad-tree, which works rather
nicely.  I would be interested to know which graph algorithms you
are implementing.

By the way, it's "vertEX", not "vertICE".
-- 
I agree with Jim Giles about many of the deficiencies of present UNIX.
Technical Details
Message-ID: <6505@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!goanna!ok
References: <ARI.HUTTUNEN.91Jun23021130@wonderwoman.hut.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.prolog
Subject: Re: Representing graphs?
Message-ID: <6505@goanna.cs.rmit.oz.au>
Date: 25 Jun 91 11:48:49 GMT
References: <ARI.HUTTUNEN.91Jun23021130@wonderwoman.hut.fi>
Distribution: comp
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 25