Exemplo n.º 1
0
  /**
   * Saves the graph according to the specifications in the configuration.
   *
   * @return always false
   */
  public boolean execute() {
    try {
      updateGraph();

      System.out.print(name + ": ");

      // initialize output streams
      FileOutputStream fos = null;
      PrintStream pstr = System.out;
      if (baseName != null) {
        String fname = fng.nextCounterName();
        fos = new FileOutputStream(fname);
        System.out.println("writing to file " + fname);
        pstr = new PrintStream(fos);
      } else System.out.println();

      if (format.equals("neighborlist")) GraphIO.writeNeighborList(g, pstr);
      else if (format.equals("edgelist")) GraphIO.writeEdgeList(g, pstr);
      else if (format.equals("chaco")) GraphIO.writeChaco(g, pstr);
      else if (format.equals("netmeter")) GraphIO.writeNetmeter(g, pstr);
      else if (format.equals("gml")) GraphIO.writeGML(g, pstr);
      else if (format.equals("dot")) GraphIO.writeDOT(g, pstr);
      else System.err.println(name + ": unsupported format " + format);

      if (fos != null) fos.close();

      return false;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Exemplo n.º 2
0
  // Control interface method.
  public boolean execute() {
    try {
      updateGraph();

      System.out.print(name + ": ");

      // initialize output streams
      String fname = fng.nextCounterName();
      FileOutputStream fos = new FileOutputStream(fname);
      System.out.println("Writing to file " + fname);
      PrintStream pstr = new PrintStream(fos);

      // dump topology:
      graphToFile(g, pstr, coordPid);

      fos.close();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    return false;
  }