Ejemplo n.º 1
0
import igraph as ig
import numpy as np

from vuln_calculator import GraphMaking

########### LOADING INPUT FILES ##############
import sys
sys.path.append('../')
from data_files import Input_files

in_files = Input_files('../../')
f_matrix_original = np.genfromtxt(in_files.get_network_file_name(),
                                  delimiter=';')
codes = np.genfromtxt(in_files.get_codes_file_name())
##############################################

relative_path = '../../results/' + in_files.get_project_name() + '/metrics/'


def export_data(codes, data, stat, thresh):
    file_out = open(relative_path + stat + '_' + str(thresh) + '.csv', 'w')
    for i in range(len(codes)):
        file_out.write(str(codes[i]) + ';' + str(data[i]) + '\n')
    file_out.close()

    # ordered version
    stat_array = []
    for i in range(len(data)):
        stat_array.append((codes[i], float(data[i])))

    dtype = [('label', int), ('stat', float)]
Ejemplo n.º 2
0
import numpy as np
import random
import matplotlib.pyplot as plt
import matplotlib


from robustness import *



########### LOADING INPUT FILES ##############
import sys
sys.path.append('../')
from data_files import Input_files

in_files = Input_files('../../') 
f_matrix_original = np.genfromtxt(in_files.get_network_file_name(),delimiter=';')
codes = np.genfromtxt(in_files.get_codes_file_name())
##############################################


N = len(codes)


relative_path_in = '../../results/' + in_files.get_project_name() + '/metrics/'
relative_path = '../../results/' + in_files.get_project_name() + '/robustness/'



print('ROBUSTNESS: ATTACKS USING THE NETWORK STATISTICS')
Ejemplo n.º 3
0
import numpy as np
import string
from datetime import date

import pandas as pd

########### LOADING INPUT FILES ##############
import sys
sys.path.append('../')
from data_files import Input_files

in_files = Input_files('../../')
f_matrix_original = np.genfromtxt(in_files.get_network_file_name(),
                                  delimiter=';')
codes = np.genfromtxt(in_files.get_codes_file_name())
##############################################

relative_path = '../../results/sort_nodes_covid-19/'

print('SORT COVID-19 CASES')

file_cities = open(relative_path + 'sorted_covid_cases_by_cities.csv', 'w')
file_cities_BRWN = open(
    relative_path + 'sorted_covid_cases_by_cities_BRWN.csv', 'w')
file_states = open(relative_path + 'sorted_covid_cases_by_states.csv', 'w')
file_cities_SP = open(relative_path + 'sorted_covid_cases_by_cities_SP.csv',
                      'w')
file_cities_MG = open(relative_path + 'sorted_covid_cases_by_cities_MG.csv',
                      'w')

file_cases_per_day = open(relative_path + 'cases_per_day.csv', 'w')
# -*- coding: utf-8 -*-

import igraph as ig
import numpy as np
import random
import matplotlib.pyplot as plt
import matplotlib

from robustness import *

########### LOADING INPUT FILES ##############
import sys
sys.path.append('../')
from data_files import Input_files

in_files = Input_files('../../')
f_matrix_original = np.genfromtxt(in_files.get_network_file_name(),
                                  delimiter=';')
codes = np.genfromtxt(in_files.get_codes_file_name())
##############################################

N = len(codes)

relative_path_in = '../../results/' + in_files.get_project_name() + '/metrics/'
relative_path = '../../results/' + in_files.get_project_name() + '/robustness/'

print('EXPORT CITIES SORTED ACOORDING TO METRICS')

# Open the IBGE cities/states files ###############################
file_name_cities = '../../input_data/IBGE_geocode_cities.csv'
Ejemplo n.º 5
0
import os
import numpy as np

########### LOADING INPUT FILES ##############
import sys
#sys.path.append('../')
from data_files import Input_files

in_files = Input_files('../')
f_matrix_original = np.genfromtxt(in_files.get_network_file_name(),
                                  delimiter=';')
codes = np.genfromtxt(in_files.get_codes_file_name())
##############################################

# creating resulting folders
path_res = '../results/' + in_files.get_project_name() + '/'

try:
    os.makedirs('../results/sort_nodes_covid-19')
except OSError:
    pass
else:
    pass

folders = ['metrics', 'robustness']

for fd in folders:
    try:
        os.makedirs(path_res + fd)
    except OSError:
        pass
Ejemplo n.º 6
0
# Latex font --------------------
rc('text', usetex=True)
font = {'family': 'normal', 'weight': 'bold', 'size': 12}

rc('font', **font)
params = {'legend.fontsize': 14}
plt.rcParams.update(params)
# -------------------------------

########### LOADING INPUT FILES ##############
import sys
sys.path.append('../')
from data_files import Input_files

in_files = Input_files('../../')
codes = np.genfromtxt(in_files.get_codes_file_name())
##############################################

N = len(codes)

relative_path_in = '../../results/' + in_files.get_project_name(
) + '/robustness/'
relative_path = '../../results/' + in_files.get_project_name() + '/'

data = np.genfromtxt('../../results/' + in_files.get_project_name() +
                     '/metrics/avg_std.csv',
                     delimiter=';')

avg = data[0]
std = data[1]