Comment 2 for bug 284380

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote :

After some failed attempts, as I see these are the possible solutions to this issue:

1. Extend/redesign the attribute handler to make it more flexible, because right now we cannot express that we are merging and combining attributes from multiple graphs, possibly with renaming them.

This is not very clean, a bigger piece of work, and unclear where else we could actually use the new, fairly difficult attribute API functions.

-------------------------------

2. Implement the whole thing in R/Python, independently of the C level. This is not really the igraph way, but attributes are probably not really used from C, anyway. Also, it might be slower. The good thing is that for R the code by Magnus is a very good starting point.

-------------------------------

3. Probably the winner. Add an optional argument to the C functions, that allows the tracking of the edges. Everything everything else in R/Python.

E.g. for intersection a possible implementation might do the following:
    1) in R, delete vertices that are not present in all graphs (based on named, obviously)
    2) permute the vertices in these subgraphs, so that the same symbolic vertices have the same internal ids
    3) call the plain C intersection function, this would return the mapping for tracking the edges
    4) copy and rename all the graph attributes to the result graph
    5) copy and rename all vertex attributes to the result graph, this is easy, because the vertex ids map to names the same way in all permuted subgraphs .
    6) copy and rename all edge attributes to the result graph, based on the tracking information returned by the C function.