@@ -0,0 +1,2167 @@
+package org.psjava.example.ds;%0A%0Aimport junit.framework.Assert;%0Aimport org.junit.Test;%0Aimport org.psjava.ds.graph.MutableDirectedWeightedGraph;%0Aimport org.psjava.ds.numbersystrem.BigIntegerNumberSystem;%0Aimport org.psjava.ds.numbersystrem.DoubleNumberSystem;%0Aimport org.psjava.ds.numbersystrem.FractionNumberSystem;%0Aimport org.psjava.ds.numbersystrem.IntegerNumberSystem;%0Aimport org.psjava.ds.numbersystrem.LongNumberSystem;%0Aimport org.psjava.ds.numbersystrem.ModularNumberSystem;%0Aimport org.psjava.goods.GoodDijkstraAlgorithm;%0A%0Aimport java.math.BigInteger;%0A%0A/**%0A * @implementation %7B@link org.psjava.ds.numbersystrem.IntegerNumberSystem%7D%0A * @implementation %7B@link org.psjava.ds.numbersystrem.BigIntegerNumberSystem%7D%0A * @implementation %7B@link org.psjava.ds.numbersystrem.FractionNumberSystem%7D%0A * @implementation %7B@link org.psjava.ds.numbersystrem.ModularNumberSystem%7D%0A *%0A * @see %7B@link org.psjava.example.algo.DijkstraAlgorithmExample%7D%0A */%0Apublic class NumberSystemExample %7B%0A%0A%09@Test%0A%09public void example() %7B%0A%09%09// psjava has %22NumberSystem%22 concept to support generalization of algorithms.%0A%09%09// For example, you can run Dijkstra's algorithm with weights in BigInteger.%0A%0A%09%09MutableDirectedWeightedGraph%3CString, BigInteger%3E g = MutableDirectedWeightedGraph.create();%0A%09%09g.insertVertex(%22A%22);%0A%09%09g.insertVertex(%22B%22);%0A%09%09g.insertVertex(%22C%22);%0A%09%09g.addEdge(%22A%22, %22B%22, new BigInteger(%2210000000000000000000000000000000000000000%22)); // So big!%0A%09%09g.addEdge(%22B%22, %22C%22, new BigInteger(%2220000000000000000000000000000000000000000%22));%0A%0A%09%09// a -%3E c must be 30000000000000000000000000000000000000000%0A%09%09BigInteger distance = GoodDijkstraAlgorithm.getInstance().calc(g, %22A%22, BigIntegerNumberSystem.getInstance()).getDistance(%22C%22);%0A%0A%09%09// Various number systems are prepared.%0A%09%09IntegerNumberSystem.getInstance();%0A%09%09LongNumberSystem.getInstance();%0A%09%09DoubleNumberSystem.getInstance();%0A%09%09FractionNumberSystem.newInstance(LongNumberSystem.getInstance()); // Given number system is used for implementation of fraction.%0A%09%09ModularNumberSystem.newInstance(IntegerNumberSystem.getInstance(), 10); // (mod 10)%0A%0A%09%09Assert.assertEquals(new BigInteger(%2230000000000000000000000000000000000000000%22), distance);%0A%09%7D%0A%0A%7D%0A

add number system example