Пример #1
0
  public void test() {
    mimaGraph graph = new mimaGraph();
    loadGraph load = new loadGraph();
    load.readData(graph, "Brightkite_edges.txt", 0, "\t");
    load.wcProb(graph);
    graph.setUniformShareProb(0.9);

    int[] seed =
        new int[] {
          29024, 16518, 35558, 34792, 33833, 8201, 1517, 10382, 33806, 23728, 35026, 84, 19380,
          24310, 34295, 2106, 17114, 4698, 827, 16188
        };
    Set<Integer> seedSet = new HashSet<Integer>();
    for (int s : seed) seedSet.add(s);
    seedSet = graph.read2Seed("BrightkiteSeed.txt");

    System.out.println("avg=" + this.avgMic(1000, seedSet, graph));
    this.printActResult(10, "set");
  }
Пример #2
0
  public Set<Integer> greedyMIC(
      int k, String dataset, String cascadeProb, double retweetAgainProb) {
    mimaGraph graph = new mimaGraph();
    loadGraph load = new loadGraph();
    load.readData(graph, dataset, 1, "\t");
    if (cascadeProb.toLowerCase().contains("w")) load.wcProb(graph);
    else if (cascadeProb.toLowerCase().contains("un")) load.uniformProb(graph, 0.3);
    graph.setUniformShareProb(retweetAgainProb);

    /////////////////////////////
    System.out.println("This is greedy algorithm in MIC model.");
    System.out.println(
        "Data: "
            + dataset
            + "\tcascade: "
            + cascadeProb
            + "\tretweet probability: "
            + retweetAgainProb);
    Set<Integer> seed = new HashSet<Integer>();

    sortedVertices sv = new sortedVertices();

    for (int i = 0; i < k; i++) {
      for (int id : graph.getAllIDs()) {
        if (seed.contains(id)) continue;
        seed.add(id);
        sv.add(new simpleVertex(id, this.avgMic(seed, graph)));
        seed.remove(id);
      }
      seed.add(sv.max().getID());
      System.out.print(sv.max().getID() + " ");
      sv.clear();
    }

    return seed;
  }