Skip to content

Commit 8c18e69

Browse files
committed
fixed minor bug in dyn graphs
1 parent 3cd0fdc commit 8c18e69

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
@@ -17,7 +17,7 @@ start.rec.log(text="CharSim")
1717
################################################################################
1818
# main parameters
1919
wide <- TRUE # wide plots showing volumes as rectangles
20-
narr.smooth <- TRUE # whether to use narrative smoothing
20+
narr.smooth <- TRUE # whether to use narrative smoothing or cumulative scene-based networks
2121
weighted <- TRUE # whether to use the graph weights
2222
sc.lim <- NA # limit on the considered scenes (NA for no limit)
2323
pub.order <- TRUE # whether to use the volume publication vs. story order
@@ -98,26 +98,26 @@ tlog(0,"Evolution of similarity between pairs of characters")
9898

9999
# similarity measures
100100
sim.meas <- list()
101-
#sim.meas[["cosine"]] <- list(
102-
# bounds=c(0,1),
103-
# cname="Cosine Similarity",
104-
# 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)))}
105-
#)
106-
#sim.meas[["pearson"]] <- list(
107-
# bounds=c(-1,1),
108-
# cname="Pearson Coefficient",
109-
# foo=function(a,idx) {sapply(1:nrow(idx), function(r) cor(x=a[idx[r,1],], y=a[idx[r,2],]))}
110-
#)
111-
#sim.meas[["euclidean"]] <- list(
112-
# bounds=c(0,NA),
113-
# cname="Euclidean Distance",
114-
# foo=function(a,idx) {sapply(1:nrow(idx), function(r) sqrt(sum((a[idx[r,1],]-a[idx[r,2],])^2)))}
115-
#)
116-
sim.meas[["regequiv"]] <- list(
101+
sim.meas[["cosine"]] <- list(
102+
bounds=c(0,1),
103+
cname="Cosine Similarity",
104+
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)))}
105+
)
106+
sim.meas[["pearson"]] <- list(
107+
bounds=c(-1,1),
108+
cname="Pearson Coefficient",
109+
foo=function(a,idx) {sapply(1:nrow(idx), function(r) cor(x=a[idx[r,1],], y=a[idx[r,2],]))}
110+
)
111+
sim.meas[["euclidean"]] <- list(
117112
bounds=c(0,NA),
118-
cname="Regular Equivalence",
119-
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]])}
113+
cname="Euclidean Distance",
114+
foo=function(a,idx) {sapply(1:nrow(idx), function(r) sqrt(sum((a[idx[r,1],]-a[idx[r,2],])^2)))}
120115
)
116+
#sim.meas[["regequiv"]] <- list(
117+
# bounds=c(0,NA),
118+
# cname="Regular Equivalence",
119+
# 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]])}
120+
#)
121121

122122
# plot parameters
123123
pal <- ATT_COLORS_FILT

0 commit comments

Comments
 (0)