-- File graphg.ads -- This is a generic graph package with an active iterator. The package -- will be used in a larger program that performs graph traversals using -- the iterator (lab6). For this purpose the iterator is not sufficient, -- in that the *iterator* marks nodes as visited when they are returned. -- This makes it impossible to correctly perform depth-first traversals. -- The flaws will be fixed in a subsequent version that students -- implement as a child package of this package. generic type Element is private; package Graphg is type Graph (Size: positive) is limited private; type Iterator is private; -- constructors procedure Clear (AGraph: in out Graph); procedure Add (ANode: in positive; WithValue: in Element; ToGraph: in out Graph); procedure InsertEdge (FromNode: in positive; ToNode: in positive; InGraph: in out Graph); -- iterator operations procedure Initialize (AnIterator: out Iterator; ForGraph: in out Graph; ToNode: in positive); procedure GetNext (IteratorNode: in out Iterator; ForGraph: in out Graph); function ValueOf (IteratorNode: in Iterator; ForGraph: in Graph) return Element; function Done (IteratorNode: in Iterator; ForGraph: in Graph) return Boolean; -- return True if all nodes adjacent to that specified by -- IteratorNode have been visited -- hidden part private type Iterator is new Positive; type GoodNode is array (positive range <>) of Boolean; type Nodes is array (positive range <>) of Element; type AdjMatrix is array (positive range <>, positive range <>) of Boolean; type Graph (Size: positive) is record InGraph: GoodNode (1..Size); Visited: GoodNode (1..Size); Values: Nodes (1..Size); Edges: AdjMatrix (1..Size, 1..Size); end record; end graphg;