DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
The C++ Graph Classes: A Tutorial - Graph(3C++) and Graph_alg(3C++)

Answering the Second Question: Which Modules are Immediately Needed to Compose Module K?

Referring back to the section, ``Example: Manufacturing Process of a Widget'', for a given module we want to determine which modules are immediately needed to compose it. One of the Vertex member functions, in_edges_g, can be used to answer this question. in_edges_g returns the set of Edge pointers (a Set_of_p) whose destination is the given Vertex. To answer the second question, we need to retrieve the source Vertex declared for each of these Edges. We'll use the Set_of_p iterator provided in the Set class, Set_of_piter, to iterate through the Edges:

       .
       .
       .
       Set_of_p<Module> mset; // create a pointer set to
                              // hold the answer set
       Set_of_piter<Transport_Time>
           si (m7->in_edges_g(widget));
       Transport_Time* t;
       while (t = si.next())
           mset.insert(t->src());
       .
       .
       .

For module K of Figure 1, mset will contain a pointer to module J.

Now that we have seen a complete example of how the Graph package can be used, let's look in detail at the Graph classes.


Next topic: The Graph Classes
Previous topic: Graphs and Sets

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004