I am using NetworkX to do the following: I have a directed graph g that I want to transform into an undirected graph h such that h has the same nodes as g and e is an edge in h iff e is bidirectional in g. For example, I want to transform:
import networkx as nx
g = nx.DiGraph([("A", "B"), ("B", "A"), ("A", "C"), ("C", "A"), ("B", "C"), ("C", "B"), ("A", "D"), ("C", "D"), ("B", "E"), ("C", "E")])
into
h = nx.Graph([("A", "B"), ("A", "C"), ("B", "C")])
h.add_nodes_from(["D", "E"])
What f(g) = h should I write in NetworkX? I think it's some combination of graph
views and filters, but I'm new to NetworkX so I'm not sure exactly what.


