Download jar file or use maven. psjava requires Java 1.6 (or above)
<dependency>
<groupId>org.psjava</groupId>
<artifactId>psjava</artifactId>
<version>0.1.19</version>
</dependency>
// psjava has "NumberSystem" concept to support generalization of algorithms. // For example, you can run Dijkstra's algorithm with weights in 32bit Integer byt also BigIntegerr. // Let's see. MutableDirectedWeightedGraph<String, BigInteger> g = MutableDirectedWeightedGraph.create(); g.insertVertex("A"); g.insertVertex("B"); g.insertVertex("C"); g.addEdge("A", "B", new BigInteger("10000000000000000000000000000000000000000")); // So big! g.addEdge("B", "C", new BigInteger("20000000000000000000000000000000000000000")); // a -> c must be 30000000000000000000000000000000000000000 BigInteger distance = GoodDijkstraAlgorithm.getInstance().calc(g, "A", BigIntegerNumberSystem.getInstance()).getDistance("C"); // Various number systems are already prepared. IntegerNumberSystem.getInstance(); LongNumberSystem.getInstance(); DoubleNumberSystem.getInstance(); FractionNumberSystem.newInstance(LongNumberSystem.getInstance()); // Given number system is used for implementation of fraction. ModularNumberSystem.newInstance(IntegerNumberSystem.getInstance(), 10); // (mod 10)
Copyright 2014 psjava team. View on GitHub