/* * Cloud9: A MapReduce Library for Hadoop * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. */ package tw.org.nchc.demo; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Collection; import java.util.List; import edu.uci.ics.jung.algorithms.cluster.WeakComponentGraphClusterer; import edu.uci.ics.jung.algorithms.importance.PageRank; import edu.uci.ics.jung.algorithms.importance.Ranking; import edu.uci.ics.jung.graph.DirectedSparseGraph; import edu.uci.ics.jung.graph.Graph; /** *
* Program that computes PageRank for a graph using the JUNG package (2.0 alpha1). Program * takes two command-line arguments: the first is a file containing the graph * data, and the second is the random jump factor (a typical setting is 0.15). *
* ** The graph should be represented as an adjacency list. Each line should have * at least one token; tokens should be tab delimited. The first token * represents the unique id of the source node; subsequent tokens represent its * link targets (i.e., outlinks from the source node). For completeness, there * should be a line representing all nodes, even nodes without outlinks (those * lines will simply contain one token, the source node id). *
* */ public class SequentialPageRank { private SequentialPageRank() { } /** * Runs the program */ public static void main(String[] args) throws IOException { if (args.length != 2) { System.err .println("usage: SequentialPageRage [graph-adjacency-list] [random-jump-factor]"); System.exit(-1); } String infile = args[0]; float alpha = Float.parseFloat(args[1]); int edgeCnt = 0; DirectedSparseGraph