Skip to content

Commit b190da8

Browse files
committed
Merge branch 'master' of ssh://git@github.com/CompNet/NaNet.git
2 parents 41f57f1 + 8c18e69 commit b190da8

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/dynamic/narr_smooth.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ ns.read.graph <- function(filtered, remove.isolates=TRUE, pub.order=TRUE)
346346
ord.fold <- "order_story"
347347

348348
base.file <- get.path.data.graph(mode="scenes", net.type="narr_smooth", order=ord.fold, filtered=filtered, pref="ns")
349-
gs <- read.dynamic.graph(base.path=base.file, remove.isolates=remove.isolates)
349+
gs <- read.dynamic.graph(base.file=base.file, remove.isolates=remove.isolates)
350350

351351
return(gs)
352352
}

src/graphs/read_write.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ write.dynamic.graph <- function(gs, base.path)
6868
#
6969
# returns: list of igraph objects representing a dynamic graph.
7070
###############################################################################
71-
read.dynamic.graph <- function(base.path, remove.isolates=TRUE)
71+
read.dynamic.graph <- function(base.file, remove.isolates=TRUE)
7272
{ tlog(2,"Reading files of the form \"",base.file,"\"")
7373
gs <- list()
7474

7575
# get folder path
76-
folder <- dirname(base.path)
77-
file <- basename(base.path)
76+
folder <- dirname(base.file)
77+
file <- basename(base.file)
7878
ll <- list.files(path=folder, pattern=paste0(file,".+"), full.names=TRUE)
7979

8080
# number of digits in the file names
@@ -85,7 +85,7 @@ read.dynamic.graph <- function(base.path, remove.isolates=TRUE)
8585
go.on <- TRUE
8686
s <- 1
8787
while(go.on)
88-
{ graph.file <- paste0(base.file,"_",s,".graphml")
88+
{ graph.file <- paste0(base.file,"_",sprintf(paste0("%0",digits,"d"),s),".graphml")
8989
if(file.exists(graph.file))
9090
{ if(s==1 || s %% 500 == 0 || s==length(gs))
9191
tlog(4, "Reading file ",graph.file)

src/post/description/char_sim.R

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ start.rec.log(text="CharSim")
1818
################################################################################
1919
# main parameters
2020
wide <- TRUE # wide plots showing volumes as rectangles
21-
narr.smooth <- TRUE # whether to use narrative smoothing
21+
narr.smooth <- TRUE # whether to use narrative smoothing or cumulative scene-based networks
2222
weighted <- TRUE # whether to use the graph weights
2323
sc.lim <- NA # limit on the considered scenes (NA for no limit)
2424
pub.order <- TRUE # whether to use the volume publication vs. story order
@@ -99,26 +99,26 @@ tlog(0,"Evolution of similarity between pairs of characters")
9999

100100
# similarity measures
101101
sim.meas <- list()
102-
#sim.meas[["cosine"]] <- list(
103-
# bounds=c(0,1),
104-
# cname="Cosine Similarity",
105-
# foo=function(a,idx) {sapply(1:nrow(idx), function(r) sum(a[idx[r,1],]*a[idx[r,2],])/sqrt(sum(a[idx[r,1],]^2)*sum(a[idx[r,2],]^2)))}
106-
#)
107-
#sim.meas[["pearson"]] <- list(
108-
# bounds=c(-1,1),
109-
# cname="Pearson Coefficient",
110-
# foo=function(a,idx) {sapply(1:nrow(idx), function(r) cor(x=a[idx[r,1],], y=a[idx[r,2],]))}
111-
#)
112-
#sim.meas[["euclidean"]] <- list(
113-
# bounds=c(0,NA),
114-
# cname="Euclidean Distance",
115-
# foo=function(a,idx) {sapply(1:nrow(idx), function(r) sqrt(sum((a[idx[r,1],]-a[idx[r,2],])^2)))}
116-
#)
117-
sim.meas[["regequiv"]] <- list(
102+
sim.meas[["cosine"]] <- list(
103+
bounds=c(0,1),
104+
cname="Cosine Similarity",
105+
foo=function(a,idx) {sapply(1:nrow(idx), function(r) sum(a[idx[r,1],]*a[idx[r,2],])/sqrt(sum(a[idx[r,1],]^2)*sum(a[idx[r,2],]^2)))}
106+
)
107+
sim.meas[["pearson"]] <- list(
108+
bounds=c(-1,1),
109+
cname="Pearson Coefficient",
110+
foo=function(a,idx) {sapply(1:nrow(idx), function(r) cor(x=a[idx[r,1],], y=a[idx[r,2],]))}
111+
)
112+
sim.meas[["euclidean"]] <- list(
118113
bounds=c(0,NA),
119-
cname="Regular Equivalence",
120-
foo=function(a,idx) {tmp <- REGE.for(M=a,E=0)$E; sapply(1:nrow(idx), function(r) tmp[idx[r,1],idx[r,2]])}
114+
cname="Euclidean Distance",
115+
foo=function(a,idx) {sapply(1:nrow(idx), function(r) sqrt(sum((a[idx[r,1],]-a[idx[r,2],])^2)))}
121116
)
117+
#sim.meas[["regequiv"]] <- list(
118+
# bounds=c(0,NA),
119+
# cname="Regular Equivalence",
120+
# foo=function(a,idx) {tmp <- REGE.for(M=a,E=0)$E; sapply(1:nrow(idx), function(r) tmp[idx[r,1],idx[r,2]])}
121+
#)
122122

123123
# plot parameters
124124
pal <- ATT_COLORS_FILT

0 commit comments

Comments
 (0)