I am trying to union two graphs. Both have same edges' attributes attribute
which is a list of values.
After the union this attribute is split into attribute_1
and attribute_2
. However I want these attributes to merge into a single attribute
, which should be a sum of these two lists.
I created a function with the following logic:
- Iterate through the edges of the merged graph to know the order of edges, and retrieve the source and target of the edge
- Find this edge in either graph1 or graph2 (by source and target) and then store the value of the
attribute
retrieved from this subgraph in the final list. - Create the attribute
attribute
in the merged graph from the final list.
Obviously due to the multiple inefficient lookups, this function takes too long to compute on large graphs.
Is there any other way to achieve the same results?