@@ -0,0 +1,2583 @@
+import sys%0Aimport commentjson as json%0Aimport os%0Aimport argparse%0Aimport numpy as np%0Aimport copy%0A%0Asys.path.append('../.')%0Asys.path.append('.')%0Afrom progressbar import ProgressBar%0A%0Aif __name__ == %22__main__%22:%0A    parser = argparse.ArgumentParser(description='Replicate nodes, links, divisions and exclusion sets N times, ' %5C%0A        'so that the total number of timeframes does not change',%0A        formatter_class=argparse.ArgumentDefaultsHelpFormatter)%0A    parser.add_argument('--model', required=True, type=str, dest='model_filename',%0A                        help='Filename of the json model description')%0A    parser.add_argument('--output', required=True, type=str, dest='result_filename',%0A                        help='Filename of the json file that will hold the replicated model')%0A    parser.add_argument('--num', type=int, dest='num', default=2,%0A                        help='how many instances of the original model shall be present in the result file')%0A    %0A    args = parser.parse_args()%0A%0A    print(%22Loading model file: %22 + args.model_filename)%0A    with open(args.model_filename, 'r') as f:%0A        model = json.load(f)%0A%0A    segmentationHypotheses = model%5B'segmentationHypotheses'%5D%0A    # use generator expression instead of list comprehension, we only need it once!%0A    maxId = max((i%5B'id'%5D for i in segmentationHypotheses)) %0A    newModel = copy.deepcopy(model)%0A%0A    for i in range(1, args.num):%0A        offset = i * (maxId + 1000000) # create random gap in IDs%0A%0A        for seg in segmentationHypotheses:%0A            newSeg = copy.deepcopy(seg)%0A            newSeg%5B'id'%5D = offset + newSeg%5B'id'%5D%0A            newModel%5B'segmentationHypotheses'%5D.append(newSeg)%0A%0A        linkingHypotheses = model%5B'linkingHypotheses'%5D%0A        for link in linkingHypotheses:%0A            newLink = copy.deepcopy(link)%0A            newLink%5B'src'%5D = offset + newLink%5B'src'%5D%0A            newLink%5B'dest'%5D = offset + newLink%5B'dest'%5D%0A            newModel%5B'linkingHypotheses'%5D.append(newLink)%0A%0A        if 'exclusions' in model:%0A            for e in model%5B'exclusions'%5D:%0A                newExclusion = %5Bx + offset for x in e%5D%0A                newModel%5B'exclusions'%5D.append(newExclusion)%0A%0A        if 'divisions' in model:%0A            for d in model%5B'divisions'%5D:%0A                newDiv = copy.deepcopy(d)%0A                newDiv%5B'parent'%5D = offset + d%5B'parent'%5D%0A                newDiv%5B'children'%5D = %5Boffset + c for c in d%5B'children'%5D%5D%0A                newModel%5B'divisions'%5D.append(newDiv)%0A            %0A    with open(args.result_filename, 'w') as f:%0A        json.dump(newModel, f, indent=4, separators=(',', ': '))%0A

Add script to artificially increase the size of graphs by replicating all nodes and their links