Example #1
0
def mergeGraphs(proc_graph, cp_graph):
    """
    Receives two graphs and merge them.
    Important to notice that the first graph has more weight
    and incorporates the second graph.
    5% of the original graph weight is disconted (decay).
    """
    for v in proc_graph.values():
        v._weight = 0.95 * v._weight

    for v in cp_graph.values():
        path = v._name
        if path in proc_graph:
            proc_graph[path]._weight += v._weight
            proc_graph[path]._time += v._time
            proc_graph[path]._count += v._count
        else:
            proc_graph[path] = Transition(path)
            proc_graph[path]._weight = v._weight
            proc_graph[path]._time = v._time
            proc_graph[path]._count = v._count