comp.lang.ada
 help / color / mirror / Atom feed
From: agate!darkstar!karplus@ames.arc.nasa.gov  (Kevin Karplus)
Subject: cyclic pointers (was  Re: Multiple Inheritance in Ada 9X/Pointers?)
Date: 11 Jan 92 05:41:10 GMT	[thread overview]
Message-ID: <26232@darkstar.ucsc.edu> (raw)

Someone (sorry, I don't have the name in front of me) asked for
examples where cyclic pointer structures were necessary for efficiency.

I have an application that may qualify.
I have a system for minimizing multi-level logic circuits, doing
technology mapping, and similar logic CAD work.
In this system, logic functions are represented as nodes on a
directed, acyclic graph.  Some of the operations create (or find)
other nodes in the graph equivalent to a particular node.  For one of
the algorithms, it is very useful to iterate over all nodes equivalent
to an arbitrary node (choosing the best of several equivalent ones,
for example).  There are many different way that two nodes can have
been found to be equivalent, and I needed a uniform way of storing
this information.  I have thousands (hundred of thousands perhaps) of
nodes, and widely varying numbers of nodes that may be equivalent, and
I needed to keep the storage cost for the equivalence information
to a minimum.

What I ended up with was an "equivalence ring"---a circularly linked
list connecting all equivalent nodes.  When two nodes are found to be
equivalent, their rings are merged, after first checking that they
aren't already on the same ring.  Note that this strucutre is
inefficient for checking equivalence (union-find structures are much
better), but is quite good for iterating over all equivalent nodes,
and costs only one pointer per node.

I submit this as a candidate for a problem in which circular linking
is a reasonable, efficient solution.  I'd be glad to hear of a better
data structure for the problem. (Send email to karplus@ce.ucsc.edu, I
don't read the comp.lang groups often enough to catch replies.)

Incidentally, if anyone is interested, I have just released an alpha
verion of this system.  It is called ITEM and the source is available by
anonymous FTP from ftp.cse.ucsc.edu.  It is 39,000 lines of c++ (gnu's
g++ to be more precise).  For all the programmers on the project
(mainly Soeren Soe and me, but also some undergrads) it is the first
significant program in C++, and so it may suffer in places from bad
habits brought over from C.

The equivalence ring structure I mentioned is in the "ite" class, in
ite/ite.h and ite/EquvalenceRing.cc.

Kevin Karplus

             reply	other threads:[~1992-01-11  5:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-01-11  5:41 Kevin Karplus [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-01-11 10:51 cyclic pointers (was Re: Multiple Inheritance in Ada 9X/Pointers? mcsun!news.funet.fi!sunic!kth.se!news.kth.se!d88-jwa
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox