def build_auxiliary_node_connectivity(G):
 directed = G.is_directed()
 mapping = {}
 H = nx.DiGraph()
 for (i, node) in enumerate(G):
  mapping[node] = i
  H.add_node(('%dA' % i), id=node)
  H.add_node(('%dB' % i), id=node)
  H.add_edge(('%dA' % i), ('%dB' % i), capacity=1)
 edges = []
 for (source, target) in G.edges():
  edges.append((('%sB' % mapping[source]), ('%sA' % mapping[target])))
  if (not directed):
   edges.append((('%sB' % mapping[target]), ('%sA' % mapping[source])))
 H.add_edges_from(edges, capacity=1)
 H.graph['mapping'] = mapping
 return H

def build_auxiliary_node_connectivity ( G ) : directed = G . is_directed ( ) mapping = { } H = nx . DiGraph ( ) for ( i , node ) in enumerate ( G ) : mapping [ node ] = i H . add_node ( ( '%dA' % i ) , id = node ) H . add_node ( ( '%dB' % i ) , id = node ) H . add_edge ( ( '%dA' % i ) , ( '%dB' % i ) , capacity = 1 ) edges = [ ] for ( source , target ) in G . edges ( ) : edges . append ( ( ( '%sB' % mapping [ source ] ) , ( '%sA' % mapping [ target ] ) ) ) if ( not directed ) : edges . append ( ( ( '%sB' % mapping [ target ] ) , ( '%sA' % mapping [ source ] ) ) ) H . add_edges_from ( edges , capacity = 1 ) H . graph [ 'mapping' ] = mapping return H
creates a directed graph d from an undirected graph g to compute flow based node connectivity .