/* -*- mode: C++ -*- */
//////////////////////////////////////////////////////////////////////////////
// FILE   : define.random.graph.tol
//////////////////////////////////////////////////////////////////////////////

//Random seed setting
Real If(ObjectExist("Real","rndSeed"), 
  PutRandomSeed(rndSeed),
  PutRandomSeed(0));
Real If(ObjectExist("Real","rndSeed"), rndSeed,
 rndSeed = GetRandomSeed(0));

WriteLn("Current Random Seed = "<<rndSeed);


Real If(ObjectExist("Real","vertex.num"), vertex.num, 
  vertex.num = IntRand(2,1000) );
Real If(ObjectExist("Real","edge.num"), edge.num, 
  edge.num = IntRand(1,(vertex.num)^1.5) );
Real If(ObjectExist("Real","directed"), directed, 
 directed = IntRand(0,1) );
Real If(ObjectExist("Real","removeRepeatedEdges"), removeRepeatedEdges, 
 removeRepeatedEdges = IntRand(0,1) );

WriteLn("Creating "+If(directed,"directed","symmetric")+
        " graph with  "<<vertex.num+ " vertices and close to "<<
        edge.num+" edges ...");
Real t0 = Copy(Time);

GraphTools::@Graph graph = GraphTools::@Graph::New("test_0001",directed);

Set vertex.names = For(1,vertex.num,Text(Real k)
{
   "Key_"<<FormatReal(k,"%06.0f")<<
       "_"+FormatReal(IntRand(0,999999999),"%09.0lf")
});

Real graph::initialize(vertex.names);

Real graph::_.edge::add.feature.numeric("Length");
Real graph::_.edge::add.feature.numeric("Hight");

VMatrix data = Mat2VMat(
  { InOut  = RandCombination(edge.num,vertex.num,2) } |
  { Length = Rand(edge.num, 1, 10, 100) } |
  { Hight  = Rand(edge.num, 1,  1,  10) });

Real graph::edge.build(data,removeRepeatedEdges);

Real t1 = Copy(Time);

WriteLn("Creating time "<<(t1-t0)+" seconds");
