From: stachour@sctc.com (Paul Stachour)
Subject: Booch Graph Component Interator Question
Date: 8 Nov 90 14:29:41 GMT [thread overview]
Message-ID: <1990Nov8.142941.7572@sctc.com> (raw)
I am using the Booch Ada components to write a program.
This program uses the directed-graph data-structure.
I use the Graph_Directed_Unbounded_Unmanaged generic package
(plus all the packages it transitively withs).
I want to iterate over all the current vertices of the graph,
to see of one of them has a particular value of a charateristic
(for purposes of discussion, having a particular "name").
I instantiate the graph-package with a STRING to contain the name
as the vertex item, and a NATURAL to be a count as the arc attribute.
Now, I have this directed graph partially built,
and I get another name-pair.
I want to find the first-name, and place an arc from that vertex
to the vertex with the second-name, updating the count on the arc
as I do so. [If the second vertex doesn't exist, I want to create
it, and place a count of 1 on the arc.]
I know that since I have a directed-graph, I could traverse all the
vertices from the base-vertex. However, this means that I would
visit some of them more than once (depnding upon the shape of the graph).
And this means I write my own iteration, which is wasteful.
So I think that the built-in interator is the way-to-go.
However, I have some problems in using the iterator as defined:
#1: Each vertex visited is an "in" parameter. That means that
changing it (by adding an arc) is forbidden. Oops!
#2: I have the new-name needed for the checking. But I don't
see an easy-way to pass it to the visiting-interator.
[I'm using a semi-global variable, but I don't consider
that very good style, or very maintainable.] Oops!
#3: If I have to create a new vertex, I'd like it to be an
output of the iterator, but I see that as similar to #2,
but in reverse. Oops!
#4: Even if all I was doing in this interator was counting
vertices whose items had some particular characteristic
(like having an "a" in the name someplace), I'd still need
to get the total out somehow? How?
How would you recommend interacting with this iterator?
I thought about using the MAP component on top of the graph one,
but this would mean that I would not have a back-mapping from
the vertex to its name, which I need also.
Thanks; Danke; Merci. ...Paul
--
Paul Stachour Secure Computing Technology Corp
stachour@sctc.com 1210 W. County Rd E, Suite 100
Arden Hills, MN 55112
[1]-(612) 482-7467
next reply other threads:[~1990-11-08 14:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-11-08 14:29 Paul Stachour [this message]
-- strict thread matches above, loose matches on Subject: below --
1990-11-12 21:00 Booch Graph Component Interator Question "", Mats Weber
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox