java link_Java Link类代码示例

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();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值