def main()

in cassovary-examples/src/main/scala/WriteRandomGraph.scala [27:47]


  def main(args: Array[String]) {
    val (graphDirectory, prefix, numNodes, avgOutDegree, numFileChunks) = if (args.length > 0) {
      (args(0), args(1), args(2).toInt, args(3).toDouble, args(4).toInt)
    } else ("/tmp", "erdos_renyi", 50, 10.0, 1)
    //val avgOutDegree = numEdges.toDouble/numNodes //math.ceil(math.log(numNodes)).toInt

    printf("Generating Erdos-Renyi random graph with %d nodes and %s avg outdegree...\n",
      numNodes, avgOutDegree)
    val genGraph = TestGraphs.generateRandomGraph(numNodes,
      TestGraphs.getProbEdgeRandomDirected(numNodes, avgOutDegree), StoredGraphDir.OnlyOut)

    // Write graph to temporary file.
    val graphFiles = (0 until numFileChunks) map { i => prefix + "_" + i + ".txt" }
    val fileWriters = graphFiles map { name =>
      new FileWriter(new File(graphDirectory, name))
    }
    printf("Writing graph with %d nodes and %s edges in dir %s to file(s) %s\n",
      genGraph.nodeCount, genGraph.edgeCount, graphDirectory, graphFiles.mkString(","))
    GraphWriter.writeDirectedGraph(genGraph, fileWriters, false, false)
    printf("Finished writing graph to files.\n")
  }