Page Rank, K-path edge, Min-cut

This commit is contained in:
Noah L. Schrick 2022-04-30 02:59:15 -05:00
parent f30cb8cd21
commit 7918b890a1
2 changed files with 18 additions and 1 deletions

View File

@ -4,6 +4,7 @@
# Noah L. Schrick - 1492657 # Noah L. Schrick - 1492657
library(igraph) library(igraph)
library(centiserve)
################## Read in the previously generated networks ################## ################## Read in the previously generated networks ##################
setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
@ -21,3 +22,16 @@ car.katz <- katz.cent(car)
hipaa.katz <- katz.cent(hipaa) hipaa.katz <- katz.cent(hipaa)
pci.katz <- katz.cent(pci) pci.katz <- katz.cent(pci)
### Page Rank
car.pr <- page.rank(car)
hipaa.pr <- page.rank(hipaa)
pci.pr <- page.rank(pci)
### K-path
car.kpe <- geokpath(car, V(car), "out")
############# Other- Tmp work
min_cut(car,"0", "2490")
min_cut(hipaa,"0","2320")
min_cut(pci,"0","60")

View File

@ -7,6 +7,9 @@ katz.cent <- function(A, alpha=NULL, beta=NULL){ #NULL sets the default value
lam.dom <- eigen(A)$values[1] #dom eigenvec lam.dom <- eigen(A)$values[1] #dom eigenvec
if (is.null(alpha)){ if (is.null(alpha)){
alpha <- 0.9 * (1/lam.dom) #Set alpha to 90% of max allowed alpha <- 0.9 * (1/lam.dom) #Set alpha to 90% of max allowed
if (is.complex(alpha)){
alpha <- Re(alpha)
}
} }
n <- nrow(A) n <- nrow(A)
@ -18,4 +21,4 @@ katz.cent <- function(A, alpha=NULL, beta=NULL){ #NULL sets the default value
scores <- solve(diag(n) - alpha*A,beta) scores <- solve(diag(n) - alpha*A,beta)
return(scores) return(scores)
} }