// // Allow a mixing of SM and SR using the morphing technique // "graph morph (type B)" in AAAI-99 // import java.util.*; public class RandomSMSR { static Random gen; static 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); } } public static void main(String[] args) throws Exception { gen = new Random(); 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) 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[] adjacent = new ArrayList[n]; // vertices adjacent to a vertex 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; adjacent[v].add(w); adjacent[w].add(v); } System.out.println(n); for (int i=0;i)adjacent[i]) System.out.print((j+1) +" "); System.out.println(); } } }