1

I recently learned how to interpret the output of networkx.optimal_edit_paths, and I am interested in generating a sequence of graphs based on the sequences of edits.

Let us suppose the example from the NetworkX documentation:

import networkx as nx
G1 = nx.cycle_graph(4)
G2 = nx.wheel_graph(5)
paths, cost = nx.optimal_edit_paths(G1, G2)

And let us suppose that we want to generate a sequence of graphs only using the edits given in paths[0]. While there does exist methods such as networkx.Graph.remove_nodes_from, networkx.Graph.remove_edges_from, and their add counterparts, they don't seem to be suited to handling the Nones or for doing so in a way that obtains a sequence of graphs.

While I could certainly code some loops and control flow of my own, is there an idiomatic way of doing this in networkx?

Galen
  • 1,128
  • 1
  • 14
  • 31

0 Answers0