#NEWLINE# def get_lca_graph( G , targets , lca_sources = None ) : #NEWLINE# #INDENT# if ( lca_sources is None ) : #NEWLINE# #INDENT# lca_sources = lowest_common_ancestors ( G , targets ) #NEWLINE# #UNINDENT# lca_graph = nx . DiGraph ( ) #NEWLINE# for source in lca_sources : #NEWLINE# #INDENT# for target in targets : #NEWLINE# #INDENT# path = nx . shortest_path ( G , source , target ) #NEWLINE# for ( frm , to ) in itertools . izip ( path [ : ( - 1 ) ] , path [ 1 : ] ) : #NEWLINE# #INDENT# lca_graph . add_edge ( frm , to ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return lca_graph