// // using p as a proportion produce an SRI // instance with p.n.(n-1)/2 edges (acceptable pairs) // import java.util.*; public class SRInstance extends SMSRInstance { int components; boolean[] visited; SRInstance(int n){ super(n); m = n*(n-1)/2; components = 0; visited = new boolean[n]; } void build(double p){ int mSR = (int)(p*m); // number of edges to select from SR mixE.clear(); shuffle(cliqueE); for (int i=0;i S = new Stack(); S.push(v); while (!S.isEmpty()){ v = S.pop(); visited[v] = true; for (int w : (ArrayList)pref[v]) if (!visited[w]) S.push(w); } return true; } public static void main(String args[]){ int n = Integer.parseInt(args[0]); // must be even double p = Double.parseDouble(args[1]); // probability pair of agents find each other acceptable SRInstance inst = new SRInstance(n); inst.trace = args.length > 2; inst.build(p); //inst.display(); System.out.println(inst.components); } }