File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -625,3 +625,24 @@ unsigned StarComplexityGen::starUpperBound(const linkRep& x) const
625
625
assert (ub>0 && complementUb>0 );
626
626
return min (ub, complementUb);
627
627
}
628
+
629
+ GraphComplexity StarComplexityGen::randomERGraph (unsigned nodes, unsigned links)
630
+ {
631
+ linkRep g=0 ;
632
+ if (links>nodes*(nodes-1 )/2 )
633
+ throw runtime_error (" links requested exceeds maximum possible: " +to_string (nodes*(nodes-1 )/2 ));
634
+ for (unsigned l=0 ; l<links; ++l)
635
+ {
636
+ unsigned node1=nodes*uni.rand (), node2;
637
+ do
638
+ node2=nodes*uni.rand ();
639
+ while (node1==node2);
640
+ g|=edge (node1,node2);
641
+ }
642
+
643
+ GraphComplexity r;
644
+ r.starComplexity =::starUpperBound (g,nodes);
645
+ NautyRep ng=toNautyRep (g, nodes);
646
+ r.complexity =ecolab::complexity (ng, true );
647
+ return r;
648
+ }
Original file line number Diff line number Diff line change 1
1
// hard code maximum number of nodes
2
- constexpr unsigned maxNodes=22 , maxStars=2 *maxNodes-1 ;
2
+ constexpr unsigned maxNodes=1000 , maxStars=2 *maxNodes-1 ;
3
3
4
4
#include " netcomplexity.h"
5
5
@@ -156,5 +156,11 @@ struct StarComplexityGen
156
156
157
157
// / return an upper bound on the number of stars in the link representation
158
158
unsigned starUpperBound (const linkRep&) const ;
159
+
160
+ // / random number generator
161
+ ecolab::urand uni;
162
+
163
+ // / randomly generate an ER graph, and return the starUpperBound and complexity
164
+ GraphComplexity randomERGraph (unsigned nodes, unsigned links);
159
165
};
160
166
You can’t perform that action at this time.
0 commit comments