Open mbojan opened 4 months ago
Not quite. The problem is that extracting subgraphs is extremely slow, so Layer()
(and others) actually store the constituent networks (with edges removed) in a hidden attribute called .subnetcache
. However, there is currently no mechanism to keep the cache up to date with the outer network, so if an attribute is created on the combined network, it won't show up when the network is "split" during initialisation.
For example, the following code works:
library(ergm.multi)
data(florentine, package = "ergm")
plot(flobusiness)
plot(flomarriage)
set.vertex.attribute(flobusiness, attrname = "x", value = 1:16)
set.vertex.attribute(flomarriage, attrname = "x", value = 1:16 + 16)
flo <- Layer(business = flobusiness, marriage = flomarriage)
flo
# Doesn't work
summary(
flo ~ L(~ edges + nodecov("x"), ~ business) +
L(~ edges + nodecov("x"), ~ marriage)
)
I should probably do some subset of the following:
Layer()
, Networks()
, and NetSeries()
, to explain that the resulting data structure should be treated as read-only, at least with respect to vertex attributes.combined_netwoks
class that will either refuse to set vertex attributes on a combined network or warn the user not to expect consistent behaviour.combined_netwoks
class that will propagate attributes to the networks in the cache, as well as any subnetworks they might have.Oh, OK. What makes the subgraph extraction a bottleneck?
network::get.inducedSubgraph()
just isn't very fast, and if you have, say, 300 small networks together in a big one, it needs to be run 300 times for every term that requires splitting them up.
This is a exegesis of this question on SO:
Brief debugging suggests that the term initialization function receives the network object stripped of all the attributes, hence
x
above is not found.