import org.nodes.Link; //导入依赖的package包/类
public static double sizeBetaCopying(DGraph graph, DGraph sub,
List> occurrences, boolean resetWiring, int iterations, double alpha)
{
int numThreads = Runtime.getRuntime().availableProcessors();
List> wiring = new ArrayList>();
Set motifNodes = new HashSet();
DGraph subbed = MotifModel.subbedGraph(graph, occurrences, wiring, motifNodes);
// * the beta model can only store simple graphs, so we translate subbed
// to a simple graph and store the multiple edges separately
FrequencyModel> removals = new FrequencyModel>();
subbed = Graphs.toSimpleDGraph((DGraph)subbed, removals);
// * The estimated cost of storing the structure of the motif and the
// structure of the subbed graph.
List samples = new ArrayList(iterations);
DSequenceEstimator motifModel = new DSequenceEstimator(sub);
DSequenceEstimator subbedModel = new DSequenceEstimator(subbed);
motifModel.nonuniform(iterations, numThreads);
subbedModel.nonuniform(iterations, numThreads);
for(int i : series(iterations))
samples.add(motifModel.logSamples().get(i) + subbedModel.logSamples().get(i));
LogNormalCI ci = new LogNormalCI(samples);
// * The rest of the graph (for which we can compute the code length
// directly)
FrequencyModel rest = new FrequencyModel();
// * parameters
rest.add("sub", DegreeSequenceModel.prior((DGraph>)sub, Prior.COMPLETE));
// * size of the subbed graph
// * degree sequence of subbed
rest.add("subbed", DegreeSequenceModel.prior((DGraph>)subbed, Prior.COMPLETE));
// * Store the labels
rest.add("labels", log2Choose(occurrences.size(), subbed.size()));
// * Any node pairs with multiple links
List additions = new ArrayList();
for(Link link : subbed.links())
if(motifNodes.contains(link.first().index()) || motifNodes.contains((link.second().index())))
{
int i = link.first().index(), j = link.second().index();
Pair pair = Pair.p(i, j);
additions.add((int)removals.frequency(pair));
}
rest.add("multi-edges", Functions.prefix(additions.isEmpty() ? 0 : (long) Functions.max(additions)));
rest.add("multi-edges", OnlineModel.storeIntegers(additions));
// * Store the rewiring information
rest.add("wiring", MotifModel.wiringBits(sub, wiring, resetWiring));
// * Store the insertion order, to preserve the precise ordering of the
// nodes in the data
rest.add("insertions", log2Factorial(graph.size()) - log2Factorial(subbed.size()));
//System.out.println("ci : " + ci.upperBound(alpha));
//rest.print(System.out);
return ci.upperBound(alpha) + rest.total();
}