0

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:

  1. Iterate through the edges of the merged graph to know the order of edges, and retrieve the source and target of the edge
  2. 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.
  3. 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?

astromonkey
  • 443
  • 2
  • 5
  • 11
  • Could you please show an example of two graphs and the intended result? In particular, what is it that you call "union"? Is it the [disjoint union](https://en.wikipedia.org/wiki/Disjoint_union_of_graphs)? Or are some vertices from the first graph expected to be merged with vertices of the second graph? – Stef Aug 10 '21 at 10:23
  • https://stackoverflow.com/questions/43011479/how-to-restore-attribute-after-union-n-igraphs/43023718#43023718 here is the close question in R – Nick Aug 13 '21 at 18:55

0 Answers0