Created
February 27, 2015 04:01
-
-
Save anvaka/4cb5ce99627949dbb4b4 to your computer and use it in GitHub Desktop.
just a page rank perf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run: | |
// echo {} > package.json | |
// npm i byline ngraph.graph ngraph.pagerank | |
var byline = require('byline'); | |
var fs = require('fs'); | |
var g = require('ngraph.graph')(); | |
var pagerank = require('ngraph.pagerank'); | |
var stream = byline.createStream(fs.createReadStream('web-Google.txt', { encoding: 'utf8' })); | |
stream.on('data', function(line) { | |
if (line[0] === '#') return; | |
var parts = line.split('\t'); | |
g.addLink(parts[0], parts[1]); | |
}); | |
stream.on('end', function () { | |
console.log("computing rank"); | |
var start = +new Date(); | |
var rank = pagerank(g, 0.80, 1e-10); | |
console.log("Done in " + (+new Date() - start) + 'ms'); | |
console.log('rank for 99: ' + rank['99']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment