当前位置: 首页>>代码示例>>C++>>正文


C++ Network::StrengthDistribution方法代码示例

本文整理汇总了C++中Network::StrengthDistribution方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::StrengthDistribution方法的具体用法?C++ Network::StrengthDistribution怎么用?C++ Network::StrengthDistribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Network的用法示例。


在下文中一共展示了Network::StrengthDistribution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char* argv[]) {
  if(argc != 2) {
    std::cerr << "Usage : ./main.out <edge_file>" << std::endl;
    exit(1);
  }

  Network network;
  std::ifstream fin(argv[1]);
  std::cerr << "Loading input file" << std::endl;
  network.LoadFile( fin );

  bool is_weighted = network.IsWeighted();
  if( ! is_weighted ) {
    std::cerr << "All the link weights are 1. Analyze the network as a non-weighted network." << std::endl;
  }

  std::pair<double,double> fc;
  if( is_weighted ) {
  std::cerr << "Conducting percolation analysis" << std::endl;
  std::ofstream lrp("link_removal_percolation.dat");
  lrp << "#fraction  weak_link_removal_lcc susceptibility strong_link_removal_lcc susceptibility" << std::endl;
  fc = network.AnalyzeLinkRemovalPercolationVariableAccuracy( 0.02, 0.005, lrp );
  lrp.flush();
  }

  std::cerr << "Calculating local clustering coefficients" << std::endl;
  network.CalculateLocalCCs();
  if( is_weighted ) {
  std::cerr << "Calculating overlaps" << std::endl;
  network.CalculateOverlaps();
  }

  std::cerr << "Calculating degree distribution" << std::endl;
  std::ofstream dd("degree_distribution.dat");
  const auto degree_distribution = network.DegreeDistribution();
  for(const auto& f : degree_distribution ) {
    dd << f.first << ' ' << f.second << std::endl;
  }
  dd.flush();

  if( is_weighted ) {
  std::cerr << "Calculating link weight distribution" << std::endl;
  // double edge_weight_bin_size = 1.0;
  std::ofstream ewd("edge_weight_distribution.dat");
  for(const auto& f : network.EdgeWeightDistributionLogBin() ) {
    ewd << f.first << ' ' << f.second << std::endl;
  }
  ewd.flush();
  }

  std::map<double, size_t> strength_distribution;
  if( is_weighted ) {
  std::cerr << "Calculating node strength distribution" << std::endl;
  double avg_s = network.AverageEdgeWeight() * network.AverageDegree();
  double strength_bin_size = avg_s * 0.01;
  std::ofstream sd("strength_distribution.dat");
  strength_distribution = network.StrengthDistribution(strength_bin_size);
  for(const auto& f :strength_distribution) {
    sd << f.first << ' ' << f.second << std::endl;
  }
  sd.flush();
  }

  std::cerr << "Calculating c(k)" << std::endl;
  std::ofstream cc_d("cc_degree_correlation.dat");
  for(const auto& f : network.CC_DegreeCorrelation() ) {
    cc_d << f.first << ' ' << f.second << std::endl;
  }
  cc_d.flush();

  if( is_weighted ) {
  std::cerr << "Calculating s(k)" << std::endl;
  std::ofstream sdc("strength_degree_correlation.dat");
  for(const auto& f : network.StrengthDegreeCorrelation() ) {
    sdc << f.first << ' ' << f.second << std::endl;
  }
  sdc.flush();
  }

  std::cerr << "Calculating k_nn(k)" << std::endl;
  std::ofstream ndc("neighbor_degree_correlation.dat");
  for(const auto& f : network.NeighborDegreeCorrelation() ) {
    ndc << f.first << ' ' << f.second << std::endl;
  }
  ndc.flush();

  if( is_weighted ) {
  std::cerr << "Calculating O(w)" << std::endl;
  std::ofstream owc("overlap_weight_correlation.dat");
  for(const auto& f : network.OverlapWeightCorrelationLogBin() ) {
    owc << f.first << ' ' << f.second << std::endl;
  }
  owc.flush();
  }

  std::cerr << "Calculating scalar values" << std::endl;
  std::ofstream fout("_output.json");
  fout << "{" << std::endl;
  fout << "  \"NumNodes\": " << network.NumNodes() << ',' << std::endl;
  fout << "  \"NumEdges\": " << network.NumEdges() << ',' << std::endl;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的Network::StrengthDistribution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。