public Graph()

in src/main/java/com/twitter/sbf/graph/Graph.java [464:493]


  public Graph(SimpleIterator<String> lines) {
    Optional<String> lineOpt;

    lineOpt = lines.next();
    if (!lineOpt.isPresent()) {
      throw new RuntimeException("No lines in input!");
    } else {
      String[] tokens = lineOpt.get().trim().split("\\s+");
      assert tokens.length == 2 || (tokens.length == 3 && tokens[2].equals("1"));
      this.numVertices = Integer.parseInt(tokens[0]);
      long expectedNumEdges = Long.parseLong(tokens[1]);
      this.neighbors = new int[this.numVertices][];
      if (tokens.length > 2 && tokens[2].equals("1")) {
        this.weights = new float[this.numVertices][];
        this.weightedOutDegrees = new float[this.numVertices];
        this.numEdges = loadWeightedGraph(lines,
            this.neighbors, this.weights, this.weightedOutDegrees, expectedNumEdges);
        globalAvgWeight = 0;
        for (float w : this.weightedOutDegrees) {
          globalAvgWeight += w;
        }
        globalAvgWeight = globalAvgWeight / this.numEdges / 2;
      } else {
        this.weights = null;
        this.numEdges = loadUnweightedGraph(lines, this.neighbors, expectedNumEdges);
      }
    }
    checkSizesOfNbrsAndWts();
    checkSymmetryAndSorting();
  }