def search_node_subg(node, location_to_reads, read_to_locations, seen):
"""
Extract the complete independent subgraph given a node, and add all subgraph nodes into the record.
Returns the nodes in this subgraph and updated record.
"""
if node in seen:
return None, seen
tmp_net=set()
queue=[node]
while(len(queue)>0):
map(tmp_net.add, queue)
map(seen.add, queue)
new_queue=deque([])
for x in queue:
x_reads=location_to_reads[x]
new_queue.extend([next_node for x_read in x_reads for next_node in read_to_locations[x_read] if not next_node in tmp_net])
queue=list(set(new_queue))
subg=list(set(tmp_net))
return subg, seen
评论列表
文章目录