Beispiel #1
0
def runImpl(params, standard = True, threadCount = 1, gpu = False, graphFileName=None):
    if graphFileName is None:
        nnode, nedge, seed = params
        graphFileName = graphName(nnode, nedge, seed)

        if not os.path.exists(graphFileName):
            # generate graph
            sys.stderr.write("Generating graph: %s \n" % str(graphFileName))
            generate_graph(nnode, nedge, seed)

        pname = cacheDir + "/" + regressionName(params, standard)
    else:
        pname = cacheDir + "/" + regressionName(params, standard, graphFileName=graphFileName)

    cmd = regressionCommand(graphFileName, standard, threadCount, gpu)
    cmdLine = " ".join(cmd)

    try:
        outFile = open(pname, 'w')
    except Exception as e:
        sys.stderr.write("Couldn't open file '%s' to write.  %s\n" % (pname, e))
        return False
    try:
        sys.stderr.write("[" + datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") + "] " + "Executing " + cmdLine + " > " + regressionName(params, standard, graphFileName=graphFileName) + "\n")
        graphProcess = subprocess.Popen(cmd, stdout = outFile)
        graphProcess.wait()
        outFile.close()
    except Exception as e:
        sys.stderr.write("Couldn't execute " + cmdLine + " > " + regressionName(params, standard, graphFileName=graphFileName) + " " + str(e) + "\n")
        outFile.close()
        return False
    return True
def ParseMessage(msg_obj):

    command = msg_obj['command']

    output = ""
    # Deal with changes in settings before everything else in case they effect monitor
    if (command == 'S'):

        setting = msg_obj['trigger_id'][2:]

        if (setting == "convertTemp"):
            monitor.fahrenheit = not monitor.fahrenheit

            if (monitor.fahrenheit):
                output = "Fahrenheit"
            else:
                output = "Celsius"

    monitor.read_sensor_data()

    if (command == 'I'):

        try:
            sensor_number = msg_obj['trigger_id'][-3]
            sensor_data = monitor.get_last_sensor_data(int(sensor_number))

            output = formatOutput(sensor_data)

        except:

            print("Nothing")

    elif (command == 'C'):

        # This is where we will get the last 10 measurments for each sensor

        data_list = {}

        for sensor_number in monitor.all_sensor_data.keys():
            data_list[sensor_number] = []
            j = -1
            for i in range(10):
                data_list[sensor_number].append(
                    formatOutput(
                        monitor.get_specific_sensor_data_records(
                            sensor_number, j)))
                j -= 1

        output = data_list

    elif (command == 'G'):
        last_10 = monitor.get_last_10()
        if monitor.fahrenheit:
            units = '(F)'
        else:
            units = '(C)'
        generate_graph(last_10, units)

    return output
 def test_generate_gc_duration_csv(self):
     expected_file = self.path + "expected_duration.csv"
     result = self.parser.parse_file(self.sample_file)
     graph.generate_graph(None, 
         graph.GC_DURATION, 
         result, 
         self.csv_writer, 
         False, 
         self.result_file)
     self.assertTrue(filecmp.cmp(self.result_file, expected_file))
 def test_generate_memory_csv(self):
     expected_file = self.path + "expected_mem.csv"
     result = self.parser.parse_file(self.sample_file)
     graph.generate_graph(None, 
         graph.YG_GC_MEMORY, 
         result, 
         self.csv_writer, 
         False, 
         self.result_file)
     self.assertTrue(filecmp.cmp(self.result_file, expected_file))
 def test_generate_gc_reclaimed_csv(self):
     expected_file = self.path + "expected_reclaimed.csv"
     result = self.parser.parse_file(self.sample_file)
     graph.generate_graph(None, 
         graph.MEMORY_RECLAIMED, 
         result, 
         self.csv_writer, 
         False, 
         self.result_file)
     self.assertTrue(filecmp.cmp(self.result_file, expected_file))
Beispiel #6
0
 def send_stock_graph(self, bot, update, args):
     symbol = ''.join(args)
     print('Requested graph: {}'.format(symbol))
     try:
         stock = Stock(symbol)
         generate_graph(bot, update.message.chat_id,
                        stock.get_historical_data(), symbol.upper())
         print('Graph sent successfully.')
     except Exception as e:
         self.send_message(bot, update, 'error')
         print('Error occured retrieving data:{}'.format(symbol))
Beispiel #7
0
def graph():
    query = request.args.get('q', None)
    _render = request.args.get('render', 'True')
    _render = False if _render == 'False' else True

    logger.debug('QUERY: ' + query)

    start_timer = datetime.now()

    if query is not None and _render:
        start, end, expressions, data_frame = parse_query(query)

        if expressions[0].name == 'metric':
            chart = generate_graph(query, start, end, data_frame)
            table = ''
        elif expressions[0].name == 'log':
            chart = '{}'
            table = generate_table(start, end, data_frame)
        else:
            logger.error("Unknown expression type: %s" % str(type(expressions[0])))
            chart = '{}'
            table = ''
    else:
        chart = "{}"
        table = ''
        # query = ''

    end_timer = datetime.now()

    logger.debug('Took %0.02fs to process this request' % (end_timer-start_timer).total_seconds())

    return render('graph.html', 'Graph', chart=chart, table=table, q=query)
Beispiel #8
0
 async def startup(app: web.Application):
     with open('RS_ViaOW.xml', 'r') as file:
         all_itinerary_viaow = parse_data(file)
     with open('RS_Via-3.xml', 'r') as file:
         all_itinerary_via3 = parse_data(file)
     all_itinerary = all_itinerary_via3 + all_itinerary_viaow
     app['graph'] = generate_graph(all_itinerary)
Beispiel #9
0
def main(file):
    lines = [x.strip(" \n").strip(';') for x in open(file).readlines()]
    triplets = detect_triplets(lines)
    triplets_dict = collect_objects_and_rels(triplets)
    node_shapes = detect_node_shapes(lines)

    return generate_graph(node_shapes, triplets_dict)
Beispiel #10
0
def main():
    args = build_parser().parse_args()
    with open(args.data_path) as file:
        data = file.read().splitlines()

    graph = generate_graph(data)
    workers_working = []
    total_time = 0
    task_order = ''

    while graph.num_free() or workers_working:
        while len(workers_working) < args.num_workers and graph.num_free():
            task = graph.next_free()
            workers_working.append(WorkingWorker(task))

        max_time_jump = min(workers_working, key=lambda x: x.time_remaining).time_remaining
        total_time += max_time_jump
        for worker in workers_working:
            worker.time_remaining = worker.time_remaining - max_time_jump
            if worker.time_remaining == 0:
                graph.remove_deps(worker.task)
                task_order += worker.task

        workers_working = [worker for worker in workers_working if worker.time_remaining > 0]

    print(task_order)
    print(total_time)
Beispiel #11
0
def save_file(b):
    try:
        fichier = filedialog.asksaveasfilename(
            filetypes=[("Portable Network Graphics",
                        "*.png"), ("Encapsulated Postcript", "*.eps"),
                       ("Portable Document Format",
                        "*.pdf"), ("Scalable Vector Graphics", "*.svg,*,svgz"),
                       ("Joint Photographic Experts Group",
                        "*.jpeg,*.jpg"), (
                            "PGF code for LaTeX",
                            "*.pgf"), ("Raw RGBA bitmap",
                                       "*.raw,*.rgba"), ("Postscript",
                                                         "*.ps")])
    except FileNotFoundError:
        messagebox.showerror(
            "error", "Problem with file path, the image has not been saved")
        return

    #Si l'utilisateur a sélecxtionné un chemin
    if fichier != "":
        dimension = read_files()
        if dimension < 1:
            return
        graphique = generate_graph(dimension, fichier, b)
        if graphique != True:
            messagebox.showerror("Error", "Can not display the graphic")
Beispiel #12
0
def test_grasp():
    _, graph = generate_graph(100, 0.5)

    solution = grasp(graph, use_path_relinking=False)
    print(solution.colors_count, solution.node_order)

    solution = grasp(graph, use_path_relinking=True)
    print(solution.colors_count, solution.node_order)
Beispiel #13
0
def main_func():
    while 1:

        def check_t(maska):
            st = maska[0][0]
            kon = maska[0][1]

            # print(st, kon)
            f = 0
            for i in range(len(maska)):
                if i == 0:
                    continue
                for j in range(len(maska)):
                    if kon == maska[j][0]:
                        kon = maska[j][1]
                        # print(kon)
                        break
                if kon == st and i < len(maska) - 1:
                    f = 1
                    break
            if f == 1:
                return False
                nt += 1
            else:
                return True

        matrix, n = graph.generate_graph()

        matrix_c = copy.deepcopy(matrix)
        """
        print(n)

        for j in range(n):
            for q in range(n):
                print(matrix[j][q], " ", end="")
            print()
            
        """

        le_road_alg, maska = MinRoadAlg.StartProc(matrix, n)

        for i in range(len(maska)):
            maska[i] = maska[i][0]

        if check_t(maska):
            break

    le_road_perebor, us_town = perebor.mainus(matrix_c, n)

    le_road_figny = figny.formicaio_main(matrix_c, n, [3.6, 3.8, 0.5, 1.0])

    print(n, le_road_perebor, le_road_alg, le_road_figny)
Beispiel #14
0
def main():
    args = build_parser().parse_args()
    with open(args.data_path) as file:
        data = file.read().splitlines()

    graph = generate_graph(data)

    task_order = ''
    while graph.num_free() > 0:
        task = graph.next_free()
        graph.remove_deps(task)
        task_order += task

    print(task_order)
Beispiel #15
0
def log_environment():

    with app.app_context():
        db = get_db()
        environment = environment_stats()

        if environment['temperature'] is None or environment[
                'humidity'] is None:
            return None

        db.execute(
            "INSERT INTO environment (env_timestamp, temperature, humidity) VALUES (?, ?, ?)",
            (environment['time'], environment['temperature'],
             environment['humidity']),
        )
        db.commit()

        # Generate weekly, daily, 6-hour, and 30min graphs graphs
        generate_graph(db_con=db,
                       time_deltas=[(datetime.now() - timedelta(minutes=30)),
                                    (datetime.now() - timedelta(hours=6)),
                                    (datetime.now() - timedelta(days=1)),
                                    (datetime.now() - timedelta(days=7))])
Beispiel #16
0
def apc_graph(scoop=""):
    def which_item(bin):
        return "Item-" + bin

    def drop(bin, type):
        if bin in scoop and type != "scoop":
            return True
        return False

    return generate_graph(
        "ABCDEFGHIJKL",
        ["grab-empty", "grab-wrong-scoop", "grab-right-scoop", "scoop"],
        "BEHK",
        which_item,
        drop,
    )
Beispiel #17
0
def main_func(Qu):
    rezult = {}

    for i in range(Qu):
        print(i)
        matrix, n = graph.generate_graph()
        time_ = time.time()
        len_, road = perebor.mainus(matrix, n)
        time_ = time.time() - time_
        rezult = [matrix, n, len_, time_]
        f = open('graph_with_len.txt', 'ta', encoding="utf-8")
        print(rezult[1], rezult[2], rezult[3], file=f)
        for j in range(rezult[1]):
            for l in range(rezult[1]):
                print(rezult[0][j][l], end=" ", file=f)
            print(file=f)

        print(file=f)
        f.close()
    return rezult
Beispiel #18
0
def affichage_fichier():

    dimension = read_files()
    if dimension < 1:
        return
    graphique = generate_graph(dimension)
    try:
        i = 0
        with open("sys/window.reso", "r") as f:
            for line in f.readlines():
                donnees = line.split()
                donnees[0] = int(donnees[0])
                if i == 0:
                    h = donnees[0]
                else:
                    l = donnees[0]
                i = i + 1

    except FileNotFoundError:
        messagebox.showerror("Error", "Can not find windows.reso file")
        return

    if graphique == True:
        can_plot.delete(ALL)
        graph_origin = PIL.Image.open('data/graphic_brut.png')
        graph_reduit = graph_origin.resize((h, l))
        img = PIL.ImageTk.PhotoImage(graph_reduit)
        dic['image'] = img
        item = can_plot.create_image(h / 2, l / 2, image=img)
        #        mon_image=PhotoImage(file=r"smiley.gif")
        #        dic['image']= mon_image
        #        img=can_plot.create_image(250,250,image=mon_image)

        fenetre.update_idletasks()
        fenetre.update()
        menubar.entryconfigure(2, state=NORMAL)

    else:
        messagebox.showerror("Error", "Can not display the graphic")
Beispiel #19
0
###################################################################################################
#                                                                                                 #
#     ways of passing arguments                                                                   #
#     1. by list                                                                                  #
#        x=[1,2,3,4,5]                                                                            #
#        y=[1,2,3,3,3]                                                                            #
#        generate_graph(x,y)                                                                      #
#                                                                                                 #
#     2. by tuples  [ (x1,y1) , (x2,y2) , (x3,y3) .... , (x10,y10)]                               #
#      data=[(1,1),(2,2),(3,3),(4,3),(5,3)]             this will generate graph as same as above #
#      generate_graph(*data)                                                                      #
#                                                                                                 #
#                                                                                                 #
###################################################################################################

from graph import generate_graph

# FOR FUN  =>> uncomment below and RUN.
#smile=[(1, 4),(1, 6),(2, 4),(2, 6),(3, 4),(3, 6),(1, 5),(3, 5),(6, 4),(6, 6),(7, 4),(7, 6),(8, 4),(8, 6),(6, 5),(8, 5),(2,2),(3,1),(4,1),(5,1),(6,1),(7,2)]
#generate_graph(*smile)

x = [1, 2, 3, 4, 5, 6, 7]
y = [1, 2, 3, 4, 3, 2, 1]
generate_graph(x, y)
Beispiel #20
0
from pyhard2.driver.digitek import DT80k
from pyhard2.driver.fluke import Fluke18x
from pyhard2.driver.ieee.scpi import ScpiPowerSupply, ScpiDCVoltmeter
from pyhard2.driver.keithley import Model6487
from pyhard2.driver.peaktech import Pt1885
from pyhard2.driver.pfeiffer import Maxigauge
from pyhard2.driver.virtual import VirtualInstrument
from pyhard2.driver.watlow import Series988

from graph import generate_graph

for driver_type in (Ngc2d,
                    CS400,
                    Controller,
                    Daq,
                    Sm700Series,
                    DT80k,
                    Fluke18x,
                    ScpiPowerSupply,
                    ScpiDCVoltmeter,
                    Model6487,
                    Pt1885,
                    Maxigauge,
                    VirtualInstrument,
                    Series988):
    driver = driver_type(drv.TesterSocket())
    name = driver.__class__.__name__
    generate_graph(name, driver, os.path.join("documentation", "gv",
                                              ".".join((name, "txt"))))

Beispiel #21
0
def presentation(function_arguments, function_values, polynomial_values, function_number, interpolation_arguments,
                 interpolation_values):
    generate_graph(function_arguments, function_values, polynomial_values, function_number, interpolation_arguments,
                   interpolation_values)
Beispiel #22
0
def StartProc():
    import graph
    import copy

    matrix, n = graph.generate_graph()  # Подключение графа
    """

    matrix = [[-2, 20, 18, 12, 8], [5, -2, 14, 7, 11], [12, 18, -2, 6, 11], [11, 17, 11, -2, 12], [5, 5, 5, 5, -2]]

    n = 5
    """
    matrix_is = copy.deepcopy(matrix)
    le_road = 0

    def main_func(matrix, matrix_is, n, le_road):

        s = 0
        for i in range(n):
            for j in range(n):
                s += matrix[i][j]

        if s == (-2 * n * n):
            return le_road, matrix

        def red_str(matrix, n):
            str_mas_min = []  # Массив с минимальными значениями в строке

            for i in range(n):  # Нахождение минимального числа
                min_zn = 1000
                for j in range(n):
                    if matrix[i][j] == -2:
                        continue
                    if matrix[i][j] < min_zn:
                        min_zn = matrix[i][j]

                str_mas_min.append(min_zn)

            for i in range(n):  # Отнимаем минимальное число из строки
                for j in range(n):
                    if matrix[i][j] == -2:
                        continue
                    matrix[i][j] -= str_mas_min[i]

            return matrix

        matrix = copy.deepcopy(red_str(matrix, n))

        def red_stl(matrix, n):
            stl_mas_min = []  # Массив с минисальным значением в столбце

            for i in range(n):  # Нахождения мимума в столбце
                min_zn = 1000
                for j in range(n):
                    if matrix[j][i] == -2:
                        continue
                    if min_zn > matrix[j][i]:
                        min_zn = matrix[j][i]

                stl_mas_min.append(min_zn)

            for i in range(n):  # Редукция по столбам(отнимаем минимум)
                for j in range(n):
                    if matrix[j][i] == -2:
                        continue
                    matrix[j][i] -= stl_mas_min[i]

            return matrix

        matrix = copy.deepcopy(red_stl(matrix, n))

        def red_tab(matrix, n):
            matrix_s = []  # Таблица с коэфицентами для ноля
            for i in range(n):  # Вычиселния коэфицента
                matrix_s.append([])
                for j in range(n):

                    if matrix[i][j] == 0:
                        min_str = 10000
                        min_stl = 10000
                        for h in range(n):
                            if h == j:
                                continue
                            if matrix[i][h] == -2:
                                continue
                            if matrix[i][h] < min_str:
                                min_str = matrix[i][h]
                        for g in range(n):
                            if g == i:
                                continue
                            if matrix[g][j] == -2:
                                continue
                            if matrix[g][j] < min_stl:
                                min_stl = matrix[g][j]

                        matrix_s[i].append(min_stl + min_str)
                    else:
                        matrix_s[i].append(-1)

            return matrix, matrix_s

        ot = red_tab(matrix, n)

        matrix, matrix_s = copy.deepcopy(ot[0]), copy.deepcopy(ot[1])

        def find_max_cof(matrix_s):
            max_cof = -3
            max_cof_kor = []
            max_cof_kor.append([])
            max_cof_kor[0] = [-1, -1]

            for i in range(n):
                for j in range(n):
                    if matrix_s[i][j] == -1:
                        continue
                    else:
                        if matrix_s[i][j] >= max_cof:
                            max_cof = matrix_s[i][j]
                            max_cof_kor[0] = [i, j]

            for i in range(n):
                for j in range(n):
                    if matrix_s[i][j] == -1:
                        continue
                    if i == max_cof_kor[0][0] and j == max_cof_kor[0][1]:
                        continue

                    if matrix[i][j] == max_cof:
                        max_cof_kor.append([i, j])

            return max_cof_kor

        max_cof_kor = find_max_cof(matrix_s)

        min_road = 10000

        for q in range(len(max_cof_kor)):

            now_road = le_road
            matrix_w = copy.deepcopy(matrix)

            now_road += matrix_is[max_cof_kor[q][0]][max_cof_kor[q][1]]

            for i in range(n):
                for j in range(n):
                    if matrix_w[i][j] == -2:
                        continue
                    if i == max_cof_kor[q][0]:
                        matrix_w[i][j] = -2
                    if j == max_cof_kor[q][1]:
                        matrix_w[i][j] = -2

            matrix_w[max_cof_kor[q][1]][max_cof_kor[q][0]] = -2

            le, matrix_w = main_func(matrix_w, matrix_is, n, now_road)

            if le <= min_road:
                min_road = le

        s = 0
        for i in range(n):
            for j in range(n):
                s += matrix_w[i][j]

        if s == (-2 * n * n):
            return le, matrix_w

        return le_road, matrix

    le_road, matrix = main_func(matrix, matrix_is, n, le_road)

    return le_road, matrix_is, n
Beispiel #23
0
    sensorsdata = serial_connection.readline().decode('UTF-8').split('/t')

    sensorairmois = float(sensorsdata[0])
    sensortemp = float(sensorsdata[1])
    sensorsoil = float(str(sensorsdata[2].strip('\r\n')))
    sensortime = str(
        datetime.datetime.fromtimestamp(int(
            time.time())).strftime('%H:%M'))  #Current Time

    #Database Operations
    mysqlcon.connect()
    mysqlcon.insert_data(sensortime, sensorairmois, sensorsoil, sensortemp)
    mysqlcon.connect()
    mysqlcon.update_data(sensortime, sensorairmois, sensorsoil, sensortemp)

    #Generate Graph
    graph_image = graph.generate_graph()

    #Flow control
    if (sensorsoil > 30):
        print(
            str('Everything is fine, Air Moisture is {}% , Soil Moisture is {}% and Temperature is {}C'
                ).format(sensorairmois, sensorsoil, sensortemp))
        time.sleep(15)

    elif (sensorsoil <= 30):
        print(
            str('Need Attention, Air Moisture is {}% , Soil Moisture is {}% and Temperature is {}C'
                ).format(sensorairmois, sensorsoil, sensortemp))
        time.sleep(15)
Beispiel #24
0
    matrices = []

    for i in range(num_nodes):
        matrices.append(
            np.matrix(
                np.random.normal(size=(range_dimension,
                                       decision_variable_size))))

    vector = sum([
        matrices[i] * np.random.normal(size=(decision_variable_size, 1))
        for i in range(num_nodes)
    ])

    # Construct graph

    graph = generate_graph(num_nodes, graph_density=graph_density)

    # Solve!
    primal, dual, primal_history, dual_history = basis_pursuit(
        matrices,
        vector,
        graph,
        num_iters=num_steps,
        solver_param=solver_param,
        gamma=gamma,
        non_smooth_one_norm=non_smooth_one_norm,
        debug_output=debugging_output)

else:

    folder = from_folder
Beispiel #25
0
#!/usr/bin/env python

import os
import argparse
import fs
import graph


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("directory", type=str,
                        help="path to the root directory of project")
    return parser.parse_args()

if __name__ == '__main__':
    args = parse_args()
    directory = os.path.abspath(args.directory)
    tree = fs.recursively_generate_directory_tree(directory)
    graph.generate_graph(tree)
Beispiel #26
0
import numpy as np
from util import measure_algorithm
from bridge_finder import BridgeFinder
from random_search import Random2BridgeFinder
from sys import setrecursionlimit
from sort import radix_sort, bucket_sort

if __name__ == '__main__':
    # graph = generate_graph(6, 0.3)
    # nx.draw_networkx(graph)
    # plt.draw()
    # plt.pause(120)
    setrecursionlimit(10000)

    sizes = list(np.linspace(10, 200, dtype=np.int, num=20))
    graphs = [generate_graph(size, p=0.3) for size in sizes]
    bf = BridgeFinder()
    random_bf_std = Random2BridgeFinder()
    random_bf_radix = Random2BridgeFinder(sort=radix_sort)
    random_bf_bucket = Random2BridgeFinder(sort=bucket_sort)

    time = measure_algorithm(bf, graphs)
    plt.plot(sizes, time)
    plt.draw()
    plt.pause(120)

    time = measure_algorithm(random_bf_std, graphs)
    plt.plot(sizes, time)
    plt.draw()
    plt.pause(120)
Beispiel #27
0
from graph import generate_graph, weight_nodes, weight_edges, get_probabilities
from greedy import greedy_celf
from enviroment import *
from information_cascade import *
import numpy as np
import time
import networkx as nx
import matplotlib.pyplot as plt
import tqdm
from LUCB_learner import *

if __name__ == "__main__":
    #features = [0.1, 0.08, 0.05, 0.02]
    n_features = 4

    graph = generate_graph(100, 5, 0.1, 1234)
    graph = weight_edges(graph, n_features)
    graph = weight_nodes(graph)

    budget = 7.5
    delta = 0.5

    # optimal with greedy_celf#
    greedy_N_simulations = 1000

    start_time = time.time()
    greedy = []
    greedy = greedy_celf(graph, budget, delta)
    opt_seeds = sorted(greedy[1])
    spread_cumulative = []
Beispiel #28
0
import graph

matrix, n = graph.generate_graph()

for i in range(n):
    print()
    for j in range(n):
        print(matrix[i][j], " ", end="")
 def test_generate_gc_duration_csv(self):
     expected_file = self.path + "expected_duration.csv"
     result = self.parser.parse_file(self.sample_file)
     graph.generate_graph(None, graph.GC_DURATION, result, self.csv_writer,
                          False, self.result_file)
     self.assertTrue(filecmp.cmp(self.result_file, expected_file))
 def test_generate_gc_reclaimed_csv(self):
     expected_file = self.path + "expected_reclaimed.csv"
     result = self.parser.parse_file(self.sample_file)
     graph.generate_graph(None, graph.MEMORY_RECLAIMED, result,
                          self.csv_writer, False, self.result_file)
     self.assertTrue(filecmp.cmp(self.result_file, expected_file))
 def test_generate_memory_csv(self):
     expected_file = self.path + "expected_mem.csv"
     result = self.parser.parse_file(self.sample_file)
     graph.generate_graph(None, graph.YG_GC_MEMORY, result, self.csv_writer,
                          False, self.result_file)
     self.assertTrue(filecmp.cmp(self.result_file, expected_file))
        todo_nodes.remove(node)
        t += 1

    # reset status of nodes of the graph to susceptible
    for n in graph.nodes():
        graph.nodes[n]['status'] = 'susceptible'

    a = [weighted_spread, triggered_nodes]
    return a


if __name__ == "__main__":

    features = [0.10, 0.08, 0.05, 0.02]

    graph = generate_graph(100, 5, 0.05, 123)
    graph = weight_edges(graph, features)
    graph = weight_nodes(graph)

    N_simulations = 100
    seed_set = [4, 8, 15, 16, 23, 42]
    spread_simulation = []

    # for u, v in graph.edges():
    #     print(u,v)
    #     for j,k in graph.edges():
    #         if (u,v) == (k,j):
    #             print("Oh no")
    #             break

    # a = []
import graph
import copy

matrix, n = graph.generate_graph()  # Подключение графа

matrix_is = copy.deepcopy(matrix)

for i in range(n):
    print()
    for j in range(n):
        print(matrix_is[i][j], " ", end="")
print()
matrix_us_town = []
le_road = 0


def main_func(matrix, matrix_is, n, le_road, matrix_us_town):
    for q in range(n):

        s = 0
        for i in range(n):
            for j in range(n):
                s += matrix[i][j]

        if s == (-2 * n):
            break

        def red_str(matrix, n):
            str_mas_min = []  # Массив с минимальными значениями в строке

            for i in range(n):  # Нахождение минимального числа
Beispiel #34
0
def display_from(email_addr):
    emails = Message.objects(from_str=email_addr).all()
    count = emails.count()
    print "%s emails found authored by '%s'" % (count, email_addr)
    g = graph.generate_graph(emails)
    graph.display_graph(g)
Beispiel #35
0
 def graph():
     dockerfiles = Path(__file__).parent / ".." / "dockerfiles"
     generate_graph({ dfile: parse_dockerfile(dockerfiles / dfile) for dfile in listdir(dockerfiles) })