@@ -72,18 +72,20 @@ extract.static.graph.scenes <- function(inter.df, char.stats, scene.stats, scene
7272if (ret.seq )
7373{# tlog(2,"Initializing the graph list")
7474s <- 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
7778if (length(scene.chars [[scenes.ord [s ]]])== 0 )
7879g <- make_empty_graph(n = 0 , directed = FALSE )
80+ # a single character: single vertex graph
7981else if (length(scene.chars [[scenes.ord [s ]]])== 1 )
8082{idx <- which(char.stats [,COL_NAME ]== scene.chars [[scenes.ord [s ]]])
8183g <- graph_from_data_frame(d = static.df , directed = FALSE , vertices = char.stats [idx ,])
8284}
8385g <- set_edge_attr(g , name = COL_OCCURRENCES , value = NA )
8486g <- set_edge_attr(g , name = COL_DURATION , value = NA )
8587res [[s ]] <- g
86- g $ SceneId <- s
88+ g $ SceneId <- scene.stats [ scenes.ord [ s ], COL_SCENE_ID ]
8789s <- s + 1
8890}
8991}
@@ -125,7 +127,7 @@ extract.static.graph.scenes <- function(inter.df, char.stats, scene.stats, scene
125127if (ret.seq )
126128{# possibly copy previous graph
127129if (! 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
130132for (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
138140static.df <- static.df [order(static.df [,COL_CHAR_FROM ],static.df [,COL_CHAR_TO ]),]
139141idx <- which(char.stats [,COL_NAME ] %in% c(cbind(static.df [,COL_CHAR_FROM ],static.df [,COL_CHAR_TO ])))
140142g <- graph_from_data_frame(d = static.df , directed = FALSE , vertices = char.stats [idx ,])
141- # g$Scene <- cur.scene
143+ g $ SceneId <- cur.scene
142144res [[cur.scene.idx ]] <- g
143145}
144146
0 commit comments