From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!msi.umn.edu!sctc.com!stachour From: stachour@sctc.com (Paul Stachour) Newsgroups: comp.lang.ada Subject: Booch Graph Component Interator Question Summary: How does one use the iterator when updating the item? Keywords: Ada Graph Interator Parameter Update Message-ID: <1990Nov8.142941.7572@sctc.com> Date: 8 Nov 90 14:29:41 GMT Organization: Secure Computing Technology Corporation List-Id: 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