I want to perform tree crossover between two graphs using the following steps:
- Select one node in each graph, the selected node must have the same type i.e. the node are objects of the same class.
- Exchange the two subgraphs that are rooted by the selected two nodes. each subgraph must be inserted in the same place of the other subgraph.
I have used ego_graph
to extract subgraph from each of the two graph, but I do not have idea how to swap the two extracted subgraphs between the two graphs.
Swapping the subtrees can be done as follows:
Note that in order for it to work you will need unique node identifiers for the 2 graphs (i.e., don't have the same node in both original graphs).