Skip to content

Commit 210a789

Browse files
committed
before major change in scene-based graph extraction method
1 parent 8bd09c0 commit 210a789

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/static/extract_graphs_scene.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,20 @@ extract.static.graph.scenes <- function(inter.df, char.stats, scene.stats, scene
7272
if(ret.seq)
7373
{#tlog(2,"Initializing the graph list")
7474
s <- 1
75-
while(scenes.ord[s]!=inter.df[is[1],COL_SCENE_ID])
75+
while(scene.stats[scenes.ord[s],COL_SCENE_ID]!=inter.df[is[1],COL_SCENE_ID])
7676
{#tlog(4,"Processing s=",s," (scenes.ord[s]=",scenes.ord[s]," and inter.df[is[1],COL_SCENE_ID]=",inter.df[is[1],COL_SCENE_ID],") -- (length(scene.chars[[s]]=",length(scene.chars[[s]]),")")
77+
# no character: empty graph
7778
if(length(scene.chars[[scenes.ord[s]]])==0)
7879
g <- make_empty_graph(n=0, directed=FALSE)
80+
# a single character: single vertex graph
7981
else if(length(scene.chars[[scenes.ord[s]]])==1)
8082
{idx <- which(char.stats[,COL_NAME]==scene.chars[[scenes.ord[s]]])
8183
g <- graph_from_data_frame(d=static.df, directed=FALSE, vertices=char.stats[idx,])
8284
}
8385
g <- set_edge_attr(g, name=COL_OCCURRENCES, value=NA)
8486
g <- set_edge_attr(g, name=COL_DURATION, value=NA)
8587
res[[s]] <- g
86-
g$SceneId <- s
88+
g$SceneId <- scene.stats[scenes.ord[s],COL_SCENE_ID]
8789
s <- s + 1
8890
}
8991
}
@@ -125,7 +127,7 @@ extract.static.graph.scenes <- function(inter.df, char.stats, scene.stats, scene
125127
if(ret.seq)
126128
{# possibly copy previous graph
127129
if(!is.na(prev.scene) && cur.scene!=prev.scene)
128-
{ tlog(4,"prev.scene=",prev.scene," cur.scene=",cur.scene)
130+
{#tlog(4,"prev.scene=",prev.scene," cur.scene=",cur.scene)
129131
# possibly several times, to represent interaction-less scenes
130132
for(s in (prev.scene.idx+1):(cur.scene.idx-1))
131133
{ tlog(6,"s=",s," scenes.ord[s-1]=",scenes.ord[s-1]," length(res)=",length(res))
@@ -138,7 +140,7 @@ extract.static.graph.scenes <- function(inter.df, char.stats, scene.stats, scene
138140
static.df <- static.df[order(static.df[,COL_CHAR_FROM],static.df[,COL_CHAR_TO]),]
139141
idx <- which(char.stats[,COL_NAME] %in% c(cbind(static.df[,COL_CHAR_FROM],static.df[,COL_CHAR_TO])))
140142
g <- graph_from_data_frame(d=static.df, directed=FALSE, vertices=char.stats[idx,])
141-
#g$Scene <- cur.scene
143+
g$SceneId <- cur.scene
142144
res[[cur.scene.idx]] <- g
143145
}
144146

0 commit comments

Comments
 (0)