Skip to content

Instantly share code, notes, and snippets.

View jagg1973's full-sized avatar

Jesus Guzman jagg1973

View GitHub Profile
@jagg1973
jagg1973 / internal-pagerank.r
Created August 14, 2019 11:29 — forked from pshapiro/internal-pagerank.r
Modification to assign PR a value between 1 and 10
library(igraph)
map <- function(x, range = c(0,1), from.range=NA) {
if(any(is.na(from.range))) from.range <- range(x, na.rm=TRUE)
## check if all values are the same
if(!diff(from.range)) return(
matrix(mean(range), ncol=ncol(x), nrow=nrow(x),
dimnames = dimnames(x)))
## map to [0,1]