Пример #1
0
HRESULT CpiRollbackConfigurePartitions(
    LPWSTR* ppwzData,
    CPI_ROLLBACK_DATA* pRollbackDataList
    )
{
    HRESULT hr = S_OK;

    int iRollbackStatus;

    CPI_PARTITION_ATTRIBUTES attrs;
    ::ZeroMemory(&attrs, sizeof(attrs));

    // read action text
    hr = CpiActionStartMessage(ppwzData, NULL == pRollbackDataList);
    ExitOnFailure(hr, "Failed to send action start message");

    // get count
    int iCnt = 0;
    hr = WcaReadIntegerFromCaData(ppwzData, &iCnt);
    ExitOnFailure(hr, "Failed to read count");

    for (int i = 0; i < iCnt; i++)
    {
        // read partition attributes from CustomActionData
        hr = ReadPartitionAttributes(ppwzData, &attrs);
        ExitOnFailure(hr, "Failed to read attributes");

        // rollback status
        hr = CpiFindRollbackStatus(pRollbackDataList, attrs.pwzKey, &iRollbackStatus);

        if (S_FALSE == hr)
            continue; // not found, nothing to rollback

        // progress message
        hr = CpiActionDataMessage(1, attrs.pwzName);
        ExitOnFailure(hr, "Failed to send progress messages");

        if (S_FALSE == hr)
            ExitFunction();

        // action
        switch (attrs.iActionType)
        {
        case atCreate:
            hr = CreatePartition(&attrs);
            if (FAILED(hr))
                WcaLog(LOGMSG_STANDARD, "Failed to create partition, hr: 0x%x, key: %S", hr, attrs.pwzKey);
            break;
        case atRemove:
            hr = RemovePartition(&attrs);
            if (FAILED(hr))
                WcaLog(LOGMSG_STANDARD, "Failed to remove partition, hr: 0x%x, key: %S", hr, attrs.pwzKey);
            break;
        }

        // check rollback status
        if (0 == iRollbackStatus)
            continue; // operation did not complete, skip progress

        // progress
        hr = WcaProgressMessage(attrs.iActionCost, FALSE);
        ExitOnFailure(hr, "Failed to update progress");
    }

    hr = S_OK;

LExit:
    // clean up
    FreePartitionAttributes(&attrs);

    return hr;
}
Пример #2
0
HRESULT CpiConfigurePartitions(
    LPWSTR* ppwzData,
    HANDLE hRollbackFile
    )
{
    HRESULT hr = S_OK;

    CPI_PARTITION_ATTRIBUTES attrs;
    ::ZeroMemory(&attrs, sizeof(attrs));

    // read action text
    hr = CpiActionStartMessage(ppwzData, FALSE);
    ExitOnFailure(hr, "Failed to send action start message");

    // ger partition count
    int iCnt = 0;
    hr = WcaReadIntegerFromCaData(ppwzData, &iCnt);
    ExitOnFailure(hr, "Failed to read count");

    // write count to rollback file
    hr = CpiWriteIntegerToRollbackFile(hRollbackFile, iCnt);
    ExitOnFailure(hr, "Failed to write count to rollback file");

    for (int i = 0; i < iCnt; i++)
    {
        // read partition attributes from CustomActionData
        hr = ReadPartitionAttributes(ppwzData, &attrs);
        ExitOnFailure(hr, "Failed to read attributes");

        // progress message
        hr = CpiActionDataMessage(1, attrs.pwzName);
        ExitOnFailure(hr, "Failed to send progress messages");

        if (S_FALSE == hr)
            ExitFunction();

        // write key to rollback file
        hr = CpiWriteKeyToRollbackFile(hRollbackFile, attrs.pwzKey);
        ExitOnFailure(hr, "Failed to write key to rollback file");

        // action
        switch (attrs.iActionType)
        {
        case atCreate:
            hr = CreatePartition(&attrs);
            ExitOnFailure1(hr, "Failed to create partition, key: %S", attrs.pwzKey);
            break;
        case atRemove:
            hr = RemovePartition(&attrs);
            ExitOnFailure1(hr, "Failed to remove partition, key: %S", attrs.pwzKey);
            break;
        }

        // write completion status to rollback file
        hr = CpiWriteIntegerToRollbackFile(hRollbackFile, 1);
        ExitOnFailure(hr, "Failed to write completion status to rollback file");

        // progress
        hr = WcaProgressMessage(attrs.iActionCost, FALSE);
        ExitOnFailure(hr, "Failed to update progress");
    }

    hr = S_OK;

LExit:
    // clean up
    FreePartitionAttributes(&attrs);

    return hr;
}
Пример #3
0
/*
  ---------------------------------------------------------------------
  
  ---------------------------------------------------------------------
*/
int
GetDecorrelationStepMB_OD(double *H,
		       double linC,
		       struct node_gra **nlist,
		       struct group **glist,
		       struct group *part,
		       int nnod,
		       int **G2G,
		       int *n2gList,
		       double **LogChooseList,
		       int LogChooseListSize,
		       double *LogFactList, int LogFactListSize,
		       double *HarmonicList,
		       gsl_rng *gen,
		       char verbose_sw)
{
  struct group *partRef;
  int step, x1, x2;
  double y1, y2;
  double mutualInfo;
  int rep, nrep=10;
  double *decay, meanDecay, sigmaDecay, result;
  int norm=0;

  x2 = nnod / 5;
  x1 = x2 / 4;

  /* Get the nrep initial estimates */
  decay = allocate_d_vec(nrep);
  for (rep=0; rep<nrep; rep++) {
    switch (verbose_sw) {
    case 'q':
      break;
    default:
      fprintf(stderr, "#\n# Estimating decorrelation time (%d/%d)\n",
	      rep + 1, nrep);
      break;
    }
    partRef = CopyPartition(part);
    for (step=0; step<=x2; step++) {
      LSMCStepMB_OD(1, H, linC, nlist, glist, part,
		 nnod, G2G, n2gList,
		 LogChooseList, LogChooseListSize,
		 LogFactList, LogFactListSize, HarmonicList,
		 gen);
      if (step == x1)
	y1 = MutualInformation(partRef, part);
    }
    y2 = MutualInformation(partRef, part);
    RemovePartition(partRef);
    decay[rep] = 2. * CalculateDecay(nnod, x1, y1, x2, y2);
    switch (verbose_sw) {
    case 'q':
      break;
    default:
      fprintf(stderr, "# Decorrelation time (estimate %d) = %g\n",
	      rep + 1, decay[rep]);
      break;
    }
    if (decay[rep] < 0) {
      rep--;
      switch (verbose_sw) {
      case 'q':
	break;
      default:
	fprintf(stderr, "#\tignoring...\n");
	break;
      }
    }
  }
  
  /* Get rid of bad estimates (Chauvenet criterion)  */
  meanDecay = mean(decay, nrep);
  sigmaDecay = stddev(decay, nrep);
  result = meanDecay * nrep;
  for (rep=0; rep<nrep; rep++) {
    if (fabs(decay[rep] - meanDecay) / sigmaDecay > 2) {
      result -= decay[rep];
      switch (verbose_sw) {
      case 'q':
	break;
      default:
	fprintf(stderr, "# Disregarding estimate %d\n", rep + 1);
	break;
      }
    }
    else {
      norm++;
    }
  }
  
  /* Clean up */
  free_d_vec(decay);

  return result / norm;
}
Пример #4
0
int main()
{
  // ----------------------------------------------------------------
  // Initialize the random number generator
  // ----------------------------------------------------------------
  gsl_rng *rand_gen;
  rand_gen = gsl_rng_alloc(gsl_rng_mt19937);
  gsl_rng_set(rand_gen, seed);

  // ----------------------------------------------------------------
  // Build the network---only use giant component
  // ----------------------------------------------------------------
  struct node_gra *total_net = NULL;
  struct node_gra *net = NULL;
  FILE *infile;

  infile = fopen("test.dat", "r");
  total_net = FBuildNetwork(infile, 0, 0, 0, 1);
  fclose(infile);
  net = GetLargestStronglyConnectedSet(total_net, 100000);

  // ----------------------------------------------------------------
  // Initialize the coclassification matrix
  // ----------------------------------------------------------------
  int i, j;
  int **coclas;
  int S = CountNodes(net);
  coclas = allocate_i_mat(S, S);
  for (i=0; i<S; i++)
    for (j=0; j<S; j++)
      coclas[i][j] = 0;

  // ----------------------------------------------------------------
  // Find the modules rep times and calculate coclassification matrix
  // ----------------------------------------------------------------
  struct group *part = NULL;
  struct node_gra *p1 = NULL;
  struct node_gra *p2 = NULL;
  for (i=0; i<rep; i++) {
    fprintf(stderr, "Repetition %d\n", i+1);
    part = SACommunityIdent(net,
			    0.0, -1.0, 0.0,
			    0.10,
			    S,         // #modules
			    'r',       // r=random initial conf
			    1,         // 0=No collective moves
			    'n',       // n=no output
			    rand_gen);
   
    // Update coclas matrix
    // --------------------------------------------------------------
    p1 = net;
    while ((p1 = p1->next) != NULL) {
      p2 = net;
      while ((p2 = p2->next) != NULL) {
	if (p1->inGroup == p2->inGroup)
	  coclas[p1->num][p2->num] += 1;
      }
    }

    // Remove the partition
    // --------------------------------------------------------------
    RemovePartition(part);
    part = NULL;
  }

  // ----------------------------------------------------------------
  // Output results
  // ----------------------------------------------------------------
  p1 = net;
  while ((p1 = p1->next) != NULL) {
    p2 = net;
    while ((p2 = p2->next) != NULL) {
      fprintf(stdout, "%s %s -1 -1 -1 -1 %lf\n",
	      p1->label, p2->label,
	      (double)coclas[p1->num][p2->num] / (double)rep);
    }
  }

  // ----------------------------------------------------------------
  // Free memory
  // ----------------------------------------------------------------
  RemoveGraph(total_net);
  RemoveGraph(net);
  free_i_mat(coclas,S);
  gsl_rng_free(rand_gen);

  return 0;
}
Пример #5
0
int main()
{
  FILE *infile=NULL;
  struct node_gra *net = NULL;
  int repeat = 1;
  gsl_rng *randGen;

  /*
    ------------------------------------------------------------
    Build the network
    ------------------------------------------------------------
  */
  infile = fopen("test_graph1.dat", "r");
  net = FBuildNetwork(infile, 0, 0, 0, 1);
  fclose(infile);
  FPrintPajekFile("graph1.net", net, 0, 0, 1);

  /*
    --------------------------------------------------------------
    Initialize the random number generator
    --------------------------------------------------------------
  */
  randGen = gsl_rng_alloc(gsl_rng_mt19937);
  gsl_rng_set(randGen, 3333);

  /*
    ------------------------------------------------------------
    Network properties
    ------------------------------------------------------------
  */
  double dtemp;
  int itemp;
  printf("S = %d\n", CountNodes(net));

  dtemp = ClusteringCoefficient(net);
  if (fabs(dtemp - 0.1875) > EPS)
    return 1;
  else
    printf("C = %g\tOK\n", dtemp);

  printf("A = %g\n", Assortativity(net));

  dtemp = AverageInverseDistance(net);
  if (fabs(dtemp - 19. / 45.) > EPS) {
    printf("P = %g\tWRONG!!\n", dtemp);
    return 1;
  }
  else
    printf("P = %g\tOK\n", dtemp);

  struct node_gra *n1 = net->next;
  struct node_gra *n2 = n1->next;
  struct node_gra *n4 = n2->next->next;
  struct node_gra *n5 = n4->next;
  struct node_gra *n8 = n5->next->next->next;
  dtemp = JaccardIndex(n1, n2);
  if (fabs(dtemp - 0.25) > EPS)
    return 1;
  else
    printf("J[1][2] = %g\tOK\n", dtemp);
  dtemp = JaccardIndex(n2, n4);
  if (fabs(dtemp - 0.50) > EPS)
    return 1;
  else
    printf("J[2][4] = %g\tOK\n", dtemp);
  dtemp = JaccardIndex(n5, n8);
  if (fabs(dtemp - 0.50) > EPS)
    return 1;
  else
    printf("J[5][8] = %g\tOK\n", dtemp);
  
  if ((itemp = CommonNeighbors(n1, n2)) != 1)
    return 1;
  else
    printf("C[1][2] = %d\tOK\n", itemp);
  if ((itemp = CommonNeighbors(n2, n4)) != 1)
    return 1;
  else
    printf("C[2][4] = %d\tOK\n", itemp);
  if ((itemp = CommonNeighbors(n5, n8)) != 2)
    return 1;
  else
    printf("C[5][8] = %d\tOK\n", itemp);
      
  /*
    ------------------------------------------------------------
    Partition
    ------------------------------------------------------------
  */
  struct group *part = NULL;
  part = SACommunityIdent(net, 2. / CountNodes(net), 0.0, 0.995,
			  2.0, 2, 'o', 1, 'n', randGen);
  MapPartToNet(part, net);
  printf("M = %g\n", Modularity(part));
  RemovePartition(part);

  /*
    ------------------------------------------------------------
    Free memory
    ------------------------------------------------------------
  */
  RemoveGraph(net);
  gsl_rng_free(randGen);

  return 0;
}
Пример #6
0
int
main(int argc, char **argv)
{
  long seed = 1111;
  FILE *inFile,*outFile;
  struct node_gra *net = NULL;
  struct node_gra *netran = NULL;
  struct node_gra *p = NULL;
  int S;
  int c;
  struct group *part = NULL;
  struct group *roles = NULL;
  int i,t1;
  int rep = 0;
  double realmod;
  double ranmodav, ranmodst;
  double *ranmodlis;
  double Tsched = 0.995, Tf = 0.0;
  double iterfac = 1.0;
  gsl_rng *rand_gen;
  char *netF;
  /*
    ------------------------------------------------------------
    Prompt for user-defined parameters
    ------------------------------------------------------------
  */
  printf ("%d\n",argc);
  if (argc == 1) {

  printf("\n# Enter random number seed (POSITIVE integer): ");
  scanf("%d", &seed);

  printf("\n# Enter the name of the network file: ");
  scanf("%s", &netF);

  printf("\n# Enter iteration factor (recommended 1.0): ");
  scanf("%lf", &iterfac);

  printf("\n# Enter the cooling factor (recommended 0.950-0.995): ");
  scanf("%lf", &Tsched);

  printf("\n# Enter the number of randomizations: ");
  scanf("%d", &rep);
  } else {
while ((c = getopt(argc, argv, "hf:s:i:c:r:")) != -1)
	  switch (c) {
	  case 'h':
		printf(USAGE ARGUMENTS);
		return -1;
		break;
	  case 'f':
		netF = optarg;
		break;
	  case 's':
		seed = atoi(optarg);
		break;
	  case 'r':
		rep = atoi(optarg);
		break;
	  case 'i':
		iterfac = atof(optarg);
		break;
	  case 'c':
		Tsched = atof(optarg);
		break;
	  }
  }
  ranmodlis = allocate_d_vec(rep);

  /*
    ------------------------------------------------------------
    Initialize the random number generator
    ------------------------------------------------------------
  */
  rand_gen = gsl_rng_alloc(gsl_rng_mt19937);
  gsl_rng_set(rand_gen, seed);

  /*
    ------------------------------------------------------------
    Build the network
    ------------------------------------------------------------
  */
  fprintf(stderr, "\n# Creating the network\n");

  inFile=fopen(netF,"r");
  net = FBuildNetwork(inFile, 0, 0, 0, 1);
  fclose(inFile);

  S = CountNodes(net);
  fprintf(stderr, "\n# The network has %d nodes\n", S);

  /*
    ------------------------------------------------------------
    Find and print the modules
    ------------------------------------------------------------
  */
  fprintf(stderr, "\n# Starting the simulated annealing\n");
  fprintf(stderr, "\n# 1/T\tM\tT\n");

  part = SACommunityIdent(net,
			  2.0 / (double)S, Tf, Tsched,
			  iterfac, 0, 'o', 1, 's', rand_gen);

  outFile = fopen("modules.dat", "w");
  FPrintPartition(outFile, part, 0);
  realmod = Modularity(part);
  fprintf(outFile, "# Modularity = %g\n", realmod);
  fclose(outFile);

  FPrintPajekFile("network.net", net, 0, 0, 1);
  FPrintPajekPartitionFile("modules.clu", net);

  /*
    ------------------------------------------------------------
    Calculate and print node properties
    ------------------------------------------------------------
  */
  outFile=fopen("node_prop.dat","w");
  p = net;
  while ((p = p->next) != NULL) {
    fprintf(outFile,"%s %d %lf %lf\n",
	    p->label, NodeDegree(p),
	    ParticipationCoefficient(p),
	    WithinModuleRelativeDegree(p, part));
  }
  fclose(outFile);

  /*
    ------------------------------------------------------------
    Find and print the roles
    ------------------------------------------------------------
  */
  fprintf(stderr, "\n# Finding node roles\n");
  roles = CatalogRoleIdent(net, part);

  outFile = fopen("roles.dat","w");
  FPrintPartition(outFile, roles, 0);
  fclose(outFile);

  MapPartToNet(roles, net);
  FPrintPajekPartitionFile("roles.clu", net);

  /*
    ------------------------------------------------------------
    Calculate properties for the randomized graph
    ------------------------------------------------------------
  */
  ranmodav = 0.0;
  for (i=0; i<rep; i++) {
    fprintf(stderr, "\nRandomization %d\n", i+1);

    RemovePartition(part);
    if ( netran != NULL)
      RemoveGraph(netran);

    netran = RandomizeSymmetricNetwork(CopyNetwork(net), 100, rand_gen);
    part = SACommunityIdent(netran,
			    2.0 / (double)S, Tf, Tsched,
			    iterfac, 0, 'o', 1, 'n', rand_gen);
    ranmodlis[i] = Modularity(part);
    ranmodav += ranmodlis[i];
  }

  /* Average and standard deviation */
  ranmodav /= (double)rep;
  ranmodst = 0.0;
  for (i=0; i<rep; i++) {
    ranmodst += (ranmodlis[i] - ranmodav) * (ranmodlis[i] - ranmodav);
  }
  ranmodst = sqrt(ranmodst / (double)rep);

  outFile = fopen("randomized_mod.dat", "w");
  fprintf(outFile, "# M\tMrand\tsimga_Mrand\n");
  fprintf(outFile, "%lf %lf %lf\n", realmod, ranmodav, ranmodst);
  fclose(outFile);

  /*
    ------------------------------------------------------------
    Free memory
    ------------------------------------------------------------
  */
  gsl_rng_free(rand_gen);
  free_d_vec(ranmodlis);
  RemovePartition(part);
  RemovePartition(roles);
  RemoveGraph(net);
  if (netran != NULL)
    RemoveGraph(netran);
  return 0;
}
Пример #7
0
main(int argc, char **argv)
{
  FILE *outF, *inF;
  int rgm;
  int seed = 1111;
  int to_file = 0;
  int from_file = 0;
  struct binet *binet = NULL;
  struct group *part = NULL;
  struct group *roles_part = NULL;
  struct node_gra *projected = NULL;
  gsl_rng *randGen;
  double degree_based = 0;
  double Ti, Tf;
  double Ts = 0.97;
  double fac = 1.0;
  double modularity = 0;
  char fn_array[256];
  char fno_array[256];
  char *file_name;
  char *file_name_out;
  int invert = 0;
  int weighted = 0;
  int output_type = 0;
  extern char *optarg;
  extern int optind;
  int c; 
  
  /*
    ------------------------------------------------------------
    Arguments parsing
    ------------------------------------------------------------
  */
  
  if (argc == 1) {
	from_file = 1;
	to_file = 1;	
	file_name = fn_array;
	file_name_out = fno_array;
	
	printf("\n# Enter random number seed (POSITIVE integer): ");
	scanf("%d", &seed);
	printf("\n# Enter the name of the network file: ");
	scanf("%s", &fn_array);

	printf("\n# Enter the name of the output file: ");
	scanf("%s", &fno_array);

	printf("\n# Enter iteration factor (recommended 1.0): ");
	scanf("%lf", &fac);
  
	printf("\n# Enter the cooling factor (recommended 0.950-0.995): ");
	scanf("%lf", &Ts);

	printf("\n# Find modules from first column (0) or second column (1): ");
	scanf("%d", &invert);

	printf("\n# Use the weighted (0) or weighted (1) modularity. (Edge weight is extracted from the third column): ");
	scanf("%d", &weighted);

	printf("\n# Use the strength (0) or degree (1) based role metrics: ");
	scanf("%d", &degree_based);


	printf("\n# Choose between tabular output (0), module partition (1) or roles partition (2):");
	scanf("%d", &output_type);}
  
  
  else{
	while ((c = getopt(argc, argv, "hwprmdf:s:i:c:o:")) != -1)
	  switch (c) {
	  case 'h':
		printf("\nUsage: bipartmod_cl [-f file] [-o file] [-s seed] [-i iter] [-c cool] [-pwmrh]\n"
			   "\nIf no arguments are provided, the program will fallback in interactive mode.\n\n"
			   "\t -f file: Name of the input network file (default: standard input)\n"
			   "\t -o file: Name of the output file (default: standard output)\n"
			   "\t -s seed: Random number seed (POSITIVE Integer, default 1111) \n"
			   "\t -i iter: Iteration factor (recommended 1.0, default 1.0)\n"
			   "\t -c cool: Cooling factor (recommended 0.950-0.995, default 0.97)\n "
			   "\t -p : Find modules for the second column (default: first) \n"
			   "\t -w : Read edge weights from the input's third column and uses the weighted modularity.\n"
			   "\t -d : Use degree based role metrics (default: strength based metrics)"
			   "\t -r : Output the roles partition rather than the default tabular output.\n"
			   "\t -m : Output the modules partition rather than the default tabular output. \n"
			   "\t -h : Display this message\n");
		return -1;
		break;
	  case 'f':
		from_file = 1;
		file_name = optarg;
		//printf("input set to %s \n", file_name);
		break;
	  case 's':
		seed = atoi(optarg);
		//printf("seed set to %d \n", seed);
		break;
	  case 'i':
		fac = atof(optarg);
		//printf("iteration factor set to %f \n", fac);
		break;
	  case 'c':
		Ts = atof(optarg);
		//printf("cooling factor set to %f. \n", Ts);
		break;
	  case 'p':
		invert = 1;
		//printf("Looking at second column.\n");
		break;
	  case 'm':
		output_type = 1;
		break;
	  case 'r':
		output_type = 2;
		break;
	  case 'o':
		to_file = 1;
		file_name_out = optarg;
		break;
	  case 'w':
		weighted = 1;
		break;
	  case 'd':
		degree_based = 1;
		break;

	  }
  }

  /*
    ------------------------------------------------------------------
    Initialize the random number generator
    ------------------------------------------------------------------
  */
  randGen = gsl_rng_alloc(gsl_rng_mt19937);
  gsl_rng_set(randGen, seed);

  /*
    ------------------------------------------------------------------
    Build the network
    ------------------------------------------------------------------
  */
  if (from_file == 1) {
	inF = fopen(file_name, "r");
	if (inF == NULL)
	  {
		printf("ERROR: No such file or directory (%s). \n", file_name);
		return(1);
	  }
	binet = FBuildNetworkBipart(inF, weighted, 0);
	fclose(inF);
  }
  else
	binet = FBuildNetworkBipart(stdin, weighted, 0);
  
  if (invert == 1)
    InvertBipart(binet);

  /*
    ------------------------------------------------------------------
    Find the modules using the bipartite network
    ------------------------------------------------------------------
  */
  Ti = 1. / (double)CountNodes(binet->net1);
  Tf = 0.;

  if (weighted == 1){
	part = SACommunityIdentBipartWeighted(binet,
										  Ti, Tf, Ts, fac,
										  0, 'o', 1, 'm',
										  randGen);
  }
  else{
	part = SACommunityIdentBipart(binet,
								  Ti, Tf, Ts, fac,
								  0, 'o', 1, 'm',
								  randGen);
  }

  // Compute the role partition if we have to.
  // Note that the roles are computed (but not as a partition)
  // if the tabular output is selected (output_type==0).
  if (output_type == 2){
	projected = ProjectBipart(binet);
	if (degree_based==1)
	  part = CatalogRoleIdent(projected,part);
	else
	  part = CatalogRoleIdentStrength(projected,part);
  }

  /*
    ------------------------------------------------------------
    Output
    ------------------------------------------------------------
  */

  if (to_file == 1)	{
	outF = fopen(file_name_out, "w");
	if (outF == NULL)
	  {
		printf("ERROR: Cannot write output (%s). \n", file_name_out);
		return(1);
	  }
	if (output_type != 0){
	  // Partition-type output (a la Netcarto).
	  FPrintPartition(outF, part, 0);
	  modularity = Modularity(part);
	  fprintf(outF, "# Modularity = %g\n", modularity);
	}
	else
	  // Tabular output. 
	  FPrintTabNodesBipart(outF, binet, part, degree_based);


	fclose(outF);
  }
  else{
	if (output_type != 0){
	  FPrintPartition(stdout, part, 0);
	  modularity = Modularity(part);
	  fprintf(stdout, "# Modularity = %g\n", modularity);
	}
	else
	  FPrintTabNodesBipart(stdout, binet, part, degree_based);
  }
  
  // Free memory
  RemovePartition(part);
  RemoveBipart(binet);
  if (output_type == 2)
	RemoveGraph(projected);
  gsl_rng_free(randGen);
}