One of the features that the API will need is the ability to "collapse" collections of nodes into a single node, and apply some sensible rule for handling the resulting connections of the "super-"node.
In practice, this will be necessary when users want to ask questions like "what is the distance from node A to region B", where region B is comprised of a number of individual, node-level areas of the brain. But the API should implement it in a general setting, because there is ultimately no reason not to.
rustworkx has an appropriate function for this, so we just need to design a sensible API and decide what we're going to do with the resulting graph - since the aforementioned function is an in-place change.
class Connections:
def collapse_nodes(self, nodes: Container[int], weight_collapse_fn)
To decide:
- How should edges be collapsed by default? Sum of weights? Maximum weight?
- Is this done in-place (the
.network attribute is directly modified)?
- If so, do we want a
.restore method or something to re-build the network from the original, lowest-level regions?
- What do we do about any metadata?
- Gut instinct is to simply carry over any metadata.
- When we have hierarchical data, we'd need to make note of the association between the assigned index of the new node and the corresponding region representing the collapse.
One of the features that the API will need is the ability to "collapse" collections of nodes into a single node, and apply some sensible rule for handling the resulting connections of the "super-"node.
In practice, this will be necessary when users want to ask questions like "what is the distance from node A to region B", where region B is comprised of a number of individual, node-level areas of the brain. But the API should implement it in a general setting, because there is ultimately no reason not to.
rustworkxhas an appropriate function for this, so we just need to design a sensible API and decide what we're going to do with the resulting graph - since the aforementioned function is an in-place change.To decide:
.networkattribute is directly modified)?.restoremethod or something to re-build the network from the original, lowest-level regions?