Reputation: 1
I am trying to create a graph package for a fixed sized complete graph but the size will not be known until runtime. I want to represent a vertex as a positive in the range 1..num_vertices. I have tried to create a generic graph package with the number of vertices as a generic parameter. This package will have to be instantiated in my code which creates visibility/scope problems for the graph package. Any suggestion? Thank you.
More Detail: Graphs is generic package
num_vertices := 4;
declare
package My_Graphs is new Graphs(num_vertices);
g: My_Graphs.Graph;
begin
...
I need to used My_Graphs in another package that contains graph algorithms.
Upvotes: 0
Views: 72
Reputation: 3358
Subtype constraints do not have to be static, so you can do things like
Max_Vertices : constant Positive := Some_Input_Function;
subtype Vertex_Number is Positive range 1 .. Max_Vertices;
Upvotes: 4