'Takes a list of nodes that have been identified to belong to a cycle,
and collapses them into on larger node.  The arcs of all nodes in
the graph must be updated to account for this.
:type new_node: Node.
:param new_node: A Node (Dictionary) to collapse the cycle nodes into.
:type cycle_path: A list of integers.
:param cycle_path: A list of node addresses, each of which is in the cycle.
:type g_graph, b_graph, c_graph: DependencyGraph
:param g_graph, b_graph, c_graph: Graphs which need to be updated.'

def collapse_nodes(self, new_node, cycle_path, g_graph, b_graph, c_graph):

    logger.debug('Collapsing    nodes...')
    for cycle_node_index in cycle_path:
        g_graph.remove_by_address(cycle_node_index)
    g_graph.add_node(new_node)
    g_graph.redirect_arcs(cycle_path, new_node['address'])
