Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

trivial

  • Loading branch information...
commit af59c2c1f25038cd7c2c0cfe6dbe5241addcc18e 1 parent ae8ef04
@smly authored
View
36 scala-practice/build.sbt
@@ -4,17 +4,35 @@ version := "0.0.1"
scalaVersion := "2.9.1"
-//resolvers ++= Seq(
-// // other resolvers here
-// "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/",
-// "ScalaNLP Maven2" at "http://repo.scalanlp.org/repo"
-//)
+scalacOptions ++= Seq("-deprecation", "-unchecked")
-libraryDependencies += "org.scalatest" %% "scalatest" % "1.7.2" % "test"
+javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation")
-libraryDependencies += "org.mockito" % "mockito-all" % "1.9.0" % "test"
+mainClass in (Compile, packageBin) := Some("com.sparsegraph.practice.Main")
-libraryDependencies += "org.apache.commons" % "commons-math3" % "3.0"
+mainClass in (Compile, run) := Some("com.sparsegraph.practice.Main")
-//libraryDependencies += "org.scalala" %% "scalala" % "1.0.0.RC2"
+// DEPENDENCIES for test
+libraryDependencies ++= Seq (
+ "org.scalacheck" %% "scalacheck" % "1.9" % "test",
+ "org.scalatest" %% "scalatest" % "1.7.2" % "test",
+ "org.mockito" % "mockito-all" % "1.9.0" % "test"
+)
+// DEPENDENCIES
+libraryDependencies ++= Seq (
+ "org.apache.commons" % "commons-math3" % "3.0"
+)
+
+logLevel := Level.Info
+
+traceLevel := 5
+
+//PROGUARD
+seq(ProguardPlugin.proguardSettings :_*)
+
+proguardOptions ++= Seq (
+ "-dontshrink -dontoptimize -dontobfuscate -dontpreverify -dontnote " +
+ "-ignorewarnings",
+ keepAllScala
+)
View
3  scala-practice/project/plugins.sbt
@@ -0,0 +1,3 @@
+libraryDependencies <+= sbtVersion { v =>
+ "com.github.siasia" %% "xsbt-proguard-plugin" % (v + "-0.1.1")
+}
View
6 scala-practice/src/main/resources/input_gr
@@ -0,0 +1,6 @@
+1 2
+1 3
+1 4
+2 3
+2 4
+4 5
View
89 scala-practice/src/main/scala/com/sparsegraph/practice/Main.scala
@@ -0,0 +1,89 @@
+package com.sparsegraph.practice
+
+import org.apache.commons.math3._
+import org.apache.commons.math3.analysis._
+import org.apache.commons.math3.analysis.function._
+import org.apache.commons.math3.analysis.integration._
+import org.apache.commons.math3.analysis.interpolation._
+import org.apache.commons.math3.analysis.polynomials._
+import org.apache.commons.math3.analysis.solvers._
+import org.apache.commons.math3.complex._
+import org.apache.commons.math3.dfp._
+import org.apache.commons.math3.distribution._
+//import org.apache.commons.math3.estimation._
+import org.apache.commons.math3.exception._
+import org.apache.commons.math3.exception.util._
+import org.apache.commons.math3.filter._
+import org.apache.commons.math3.fraction._
+import org.apache.commons.math3.genetics._
+import org.apache.commons.math3.geometry._
+import org.apache.commons.math3.geometry.euclidean.oned._
+import org.apache.commons.math3.geometry.euclidean.threed._
+import org.apache.commons.math3.geometry.euclidean.twod._
+import org.apache.commons.math3.geometry.partitioning._
+import org.apache.commons.math3.geometry.partitioning.utilities._
+import org.apache.commons.math3.ode._
+import org.apache.commons.math3.ode.events._
+import org.apache.commons.math3.ode.nonstiff._
+import org.apache.commons.math3.ode.sampling._
+import org.apache.commons.math3.optimization._
+import org.apache.commons.math3.optimization.direct._
+import org.apache.commons.math3.optimization.fitting._
+import org.apache.commons.math3.optimization.general._
+import org.apache.commons.math3.optimization.linear._
+import org.apache.commons.math3.optimization.univariate._
+import org.apache.commons.math3.random._
+import org.apache.commons.math3.special._
+import org.apache.commons.math3.stat.clustering._
+import org.apache.commons.math3.stat.correlation._
+import org.apache.commons.math3.stat.descriptive._
+import org.apache.commons.math3.stat.descriptive.moment._
+import org.apache.commons.math3.stat.descriptive.rank._
+import org.apache.commons.math3.stat.descriptive.summary._
+import org.apache.commons.math3.stat.inference._
+import org.apache.commons.math3.stat.ranking._
+import org.apache.commons.math3.stat.regression._
+import org.apache.commons.math3.transform._
+import org.apache.commons.math3.util._
+
+import scala.collection.mutable.HashMap
+
+object Main {
+ val randomData = new RandomDataImpl()
+ var edges = new HashMap[Int, Int]
+
+ def drowProb(prob: Long): Boolean = {
+ (randomData.nextLong(0, 100) < prob)
+ }
+
+ def read(in: java.io.InputStream, f:(String) => Unit) = {
+ try {
+ val reader = new java.io.BufferedReader( new java.io.InputStreamReader(in) )
+ var line: String = null
+
+ while ( { line = reader.readLine; line != null} ) f(line)
+ } finally {
+ in.close
+ }
+ }
+
+ def main(args: Array[String]) {
+ val path = "./src/main/resources/input_gr"
+ val in = new java.io.FileInputStream(path)
+
+ read(in, (l:String) => {
+ val elems = l.split("\t")
+ if (elems.size ==2) edges += (elems(0).toInt -> elems(1).toInt)
+ })
+
+ /*
+ val trial = 10000
+ for (probInfect <- 0 until 30) {
+ var c = 0; for (i <- 0 until 100 * trial)
+ if (drowProb(probInfect)) c += 1
+
+ printf("Prob: %.3f / Gen: %d\n", c * 1.0 / trial, probInfect)
+ }
+ */
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.