// // Allow a mixing of SM and SR using the morphing technique // "graph morph (type B)" in AAAI-99 // import java.util.*; public class SMSRInstance { Random gen; int n; // number of agents, even double p; // (1.0-p) from SM (p=0 <-> SM), p from SR (p=1 <-> SR) ArrayList[] pref; // preference list of agents void shuffle(ArrayList v){ int j,n; n = v.size(); int temp; for (int i=n-1;i>0;i--){ j = gen.nextInt(i+1); temp = v.get(i); v.set(i,v.get(j)); v.set(j,temp); } } // // Knuth shuffle of integer vector // SMSRInstance(int n, double p){ gen = new Random(); this.n = n; this.p = p; pref = new ArrayList[n]; int m = (n*n)/4; // number of edges int mSR = (int)(p*m); // number of edges to select from SR int mSM = m - mSR; // number of edges to select from SM int mIntersection = 0; // thes size of the intersection between smE and srE ArrayList cliqueE = new ArrayList(); // all possible edges ArrayList smE = new ArrayList(); // edges in SM ArrayList srE = new ArrayList(); // edges in SR (with same number of edges in SM) ArrayList mixE = new ArrayList(); // edges in mixed SM & SR, of size m ArrayList deleteE = new ArrayList(); // edges to delete // // create edges in complete bipartite graph smE // for (int i=0;i(); for (Integer e : mixE){ int v = e/n; int w = e%n; pref[v].add(w); pref[w].add(v); } for (int i=0;i)pref[i]) System.out.print((j+1) +" "); System.out.println(); } } public static void main(String args[]){ int n = Integer.parseInt(args[0]); // must be even double p = Double.parseDouble(args[1]); // (1.0-p) from SM (p=0 <-> SM), p from SR (p=1 <-> SR) SMSRInstance inst = null; for (int i=0;i<100000;i++) inst = new SMSRInstance(n,p); //inst.display(); } }