Esempio n. 1
0
def graphml2mat(ingraph, outgraph, prune=False):
    ing = Graph.Read_GraphML(ingraph)

    if sum(ing.es()[:]['weight']) < 500000:
        print 'bad graph? ecount= ', sum(ing.es()[:]['weight'])
        print 'filename= ', ingraph
        return

    #currently being done in graphgen so don't need to delete vertex 0
    #ing.vs[0].delete()
    if prune:
        #delete zero degree nodes
        #GK TODO: be smarter
        i = list()
        for n, v in enumerate(ing.vs):
            if v.degree() == 0:
                i.append(n)
        ing.vs[i].delete()

    outg = lil_matrix((ing.vcount(), ing.vcount()))
    #import pdb; pdb.set_trace()
    for e in ing.es:
        outg[e.source, e.target] = e['weight']
        outg[e.target,
             e.source] = e['weight']  #since edges are undirected add both ways

    outg = triu(outg)
    mat_dict = {"graph": outg}
    savemat(outgraph, mat_dict)
Esempio n. 2
0
    def testGraphML(self):
        with temporary_file(
            """\
            <?xml version="1.0" encoding="UTF-8"?>
            <graphml xmlns="http://graphml.graphdrawing.org/xmlns"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
                    http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
            <!-- Created by igraph -->
            <key id="v_name" for="node" attr.name="name" attr.type="string"/>
            <graph id="G" edgedefault="undirected">
                <node id="n0">
                <data key="v_name">a</data>
                </node>
                <node id="n1">
                <data key="v_name">b</data>
                </node>
                <node id="n2">
                <data key="v_name">c</data>
                </node>
                <node id="n3">
                <data key="v_name">d</data>
                </node>
                <node id="n4">
                <data key="v_name">e</data>
                </node>
                <node id="n5">
                <data key="v_name">f</data>
                </node>
                <edge source="n0" target="n1">
                </edge>
                <edge source="n0" target="n2">
                </edge>
                <edge source="n0" target="n3">
                </edge>
                <edge source="n1" target="n2">
                </edge>
                <edge source="n3" target="n4">
                </edge>
                <edge source="n3" target="n5">
                </edge>
                <edge source="n4" target="n5">
                </edge>
            </graph>
            </graphml>
        """
        ) as tmpfname:
            try:
                g = Graph.Read_GraphML(tmpfname)
            except NotImplementedError as e:
                self.skipTest(str(e))

            self.assertTrue(isinstance(g, Graph))
            self.assertEqual(g.vcount(), 6)
            self.assertEqual(g.ecount(), 7)
            self.assertFalse(g.is_directed())
            self.assertTrue("name" in g.vertex_attributes())

            g.write_graphml(tmpfname)
Esempio n. 3
0
def get_housing_graphs():
    from igraph import Graph
    import os   
    # some housing graphs
    h_files = ['RoomNet.graphml','FloorNet.graphml']
    hgraphs=[Graph.Read_GraphML(os.path.join(hnet_dir, hf)) for hf in h_files]
    hlayer_names = ['roommate','floor']
    return hgraphs, hlayer_names
Esempio n. 4
0
def get_classroom_graphs():
    from igraph import Graph
    import os   
    net_dir = '../../../Data/networks'
    class_files = ['ClassNetPlatoonM.graphml','ClassNetPlatoonT.graphml',]
    graphs = [Graph.Read_GraphML(os.path.join(net_dir, cf)) for cf in class_files]
    class_layer_names = ['mon','tue'] 
    return graphs, class_layer_names
Esempio n. 5
0
    def set_graph(self, graph_path):
        self.graph = Graph.Read_GraphML(graph_path)

        if 'x' not in self.graph.vs.attributes() or 'nan' in str(
                self.graph.vs['x']):
            self.set_layout('Random')

        self.setup_availability()

        self.view.update()
Esempio n. 6
0
def get_graphs_stats(path):
    '''
    Params: path to corpus of GraphML files
    Returns: total count of nodes and edges in all graphs
    '''

    tot_nodes = 0
    tot_edges = 0
    for g in os.listdir(path):
        G = Graph.Read_GraphML(os.path.join(path, g))
        tot_nodes += G.vcount()
        tot_edges += G.ecount()
    return tot_nodes, tot_edges
Esempio n. 7
0
def load_graphs(corpus):

    G = []
    classes = []
    for c in os.listdir(corpus):
        for g in os.listdir(os.path.join(corpus, c)):
            classes.append(c)
            graph = Graph.Read_GraphML(os.path.join(os.path.join(corpus, c),
                                                    g))
            G.append(graph)

    ad_list = get_adj_list(G)
    node_label = get_node_labels(G)
    return node_label, ad_list, OrderedCounter(classes)
Esempio n. 8
0
def GetGraphList(pointList):
    global Categary, Num

    pointsGraphList = []
    for i in range(len(pointList)):  # 5个图
        distanceArray = GetPointsAarry(pointList[i])  # 获得图的距离矩阵
        graphmlFileName = GetGraphmlFile(distanceArray,
                                         pointList[i])  # 将矩阵转换为graphml格式,并生成文件
        pointsGraph = Graph.Read_GraphML(graphmlFileName)  # 读取文件,生成图网络
        pointsGraphList.append(pointsGraph)
        Num = Num + 1
        if Num > 4:
            Num = 0
    Categary = Categary + 1
    return pointsGraphList
Esempio n. 9
0
def loadTagHierarchyList(f_taghierachy):
    tagtree = Graph.Read_GraphML(f_taghierachy)
    tags = {}
    #tags={tag:[ancestor0,ancestor1]}
    for v in [v for v in tagtree.vs if v.degree() > 0]:
        tag = v['name'][1:]
        parents = []
        while (True):
            neighbors = v.neighbors(mode=igraph.OUT)
            if len(neighbors):
                parent = neighbors[0]
                parents.insert(0, parent['name'][1:])
                v = parent
            else:
                break
        tags[tag] = parents.insert(0, '__root__')
        parents.append(tag)
        tags[tag] = parents
    return tags
Esempio n. 10
0
def load():
    GRAPH_COUNT = 8
    graphs = []
    for graph_num in range(5, 6):
        print 'loaded %d' % graph_num
        graphs.append(Graph.Read_GraphML('graph%d.graphml' % graph_num))
    graphs_return = []
    # CHANGE HERE FOR ALL GRAPHS
    # graph = graphs[2]
    for graph in graphs:
        mygraph = MyGraph()
        count = 0
        for vertex in graph.vs:
            mygraph.add_single_node(count, graphmlid=vertex["id"])
            edges = graph.es.select(_source=count)
            for edge in edges:
                source, target = edge.tuple
                mygraph.add_single_edge(source, target, weight=1)
            count += 1
        graphs_return.append(mygraph)
    print graphs_return
    return graphs_return
Esempio n. 11
0
    def search_final_results(self, search_res, company_id, doc_id):
        #graph_path = "/root/databuilder_train_ui/tenkTraining/Data_Builder_Training_Copy/pysrc/graphlbv/tablets_"+str(company_id)+"/"+str(doc_id)+"/" 
        graph_path = "/root/databuilder_train_ui/tenkTraining/Data_Builder_Training_Copy/pysrc/graphlbv/"+str(company_id)+"/"+str(doc_id)+"/" 
        fname_dict = {}
        for search_elm in search_res:
            search_elm_sp = search_elm.split('#')
            hkeycol = search_elm_sp[0]+'#'+search_elm_sp[1]
            fname = search_elm_sp[2]
            if fname not in fname_dict:
               fname_dict[fname] = []   
            fname_dict[fname].append(hkeycol)

        results = []
        for fname, vs in fname_dict.items():
            gpath = graph_path + fname
            print 'gpath', gpath
            G = Graph.Read_GraphML(gpath)
            all_formula_vs = G.vs.select(lambda v:v["hashkeycol"] in vs) #graph.vs.select(lambda vertex: vertex.index % 2 == 1)
            for v in all_formula_vs:
                results.append((v['table_types'], v['grp_id'], v['row_taxo_id'], v['col'], v['hashkey'], fname))
            del G
        return results      
Esempio n. 12
0
def load_graphml(filenames_graphs, filename_labels):
    G = []
    for fname in filenames_graphs:
        G.append(Graph.Read_GraphML(fname))
    Y = genfromtxt(filename_labels)
    return (G, Y)
Esempio n. 13
0
    feature_vector += str(JCMatrix[nodei][nodej]) + " "
    feature_vector += str(CNMatrix[nodei][nodej]) + " "
    feature_vector += str(PAMatrix[nodei][nodej]) + " "
    feature_vector += str(SPMatrix[nodei][nodej]) + " "
    feature_vector += str(betweenness[nodei][nodej]) + " "
    feature_vector += str(dailyRate[nodei]) + " "

    return feature_vector


if __name__ == '__main__':

    #Tranforming Graph to features
    for date in range(1, 31):

        DataGraph = Graph.Read_GraphML("Data/trades-timestamped-2009-12-" +
                                       str(date) + ".graphml")
        print("trades-timestamped-2009-12-" + str(date) + ".graphml")

        feature_vector = ""
        AAMatrix, JCMatrix, CNMatrix, PAMatrix, SPMatrix, betweenness, dailyRate = FeatureMatrix(
            DataGraph, date)
        AA = DataGraph.get_adjacency()
        if (date <= 24):
            DataSetFile = open("./TrainTest/TrainDataSet_Trades_Network.txt",
                               "a")
            print("TrainDataSet_Trades_Network.txt for day", date)
        else:
            DataSetFile = open("./TrainTest/TestingDataSet_Trades_Network.txt",
                               "a")
            print("TestingDataSet_Trades_Network.txt for day", date)
Esempio n. 14
0
"""
Converting mutag to list format
"""

from igraph import Graph
import numpy as np

mutag_list = []

n_graphs = 188
for i in xrange(n_graphs):

    g_cur = Graph.Read_GraphML(
        "/home/eghisu/projects/gk_python_wrapper/gk_python_c/data/mutag/mutag_%d.graphml"
        % (i + 1))
    mutag_list.append(g_cur)

np.save(
    "/home/eghisu/projects/gk_python_wrapper/gk_python_c/data/mutag_pydata",
    mutag_list)
import sys
import matplotlib

matplotlib.use("Qt5Agg")
from PyQt5 import QtWidgets

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

from igraph import Graph
import matplotlib.pyplot as plt
import numpy as np

graph = Graph.Read_GraphML("./NREN.graphml")


class DataBar(FigureCanvas):
    node_list = []
    edge_list = []

    def __init__(self, parent=None, width=5, height=4, dpi=100):
        self.fig = Figure(figsize=(width, height), dpi=dpi)

        self.axes = self.fig.add_subplot(111)

        # self.axes.set_axis_off()

        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding,
Esempio n. 16
0
os.makedirs(plot_dir, exist_ok=True)

#%%
# =============================================================================
#  Build class networks
# =============================================================================
class_files = [
    'ClassNetPlatoonU.graphml',
    'ClassNetPlatoonM.graphml',
    'ClassNetPlatoonT.graphml',
    'ClassNetPlatoonW.graphml',
    'ClassNetPlatoonR.graphml',
    'ClassNetPlatoonF.graphml',
    'ClassNetPlatoonS.graphml',
]
graphs = [Graph.Read_GraphML(os.path.join(net_dir, cf)) for cf in class_files]

class_layer_names = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']
class_contacts = bu.get_all_class_contacts_dicts(graphs, class_layer_names, 3)

#%%
# =============================================================================
#  Build housing networks
# =============================================================================
h_files = ['RoomNet.graphml', 'HouseholdNet_10.graphml', 'FloorNet.graphml']
hgraphs = [Graph.Read_GraphML(os.path.join(hnet_dir, hf)) for hf in h_files]

hlayer_names = ['roommate', 'household', 'floor']
household_contacts = bu.get_all_housing_contacts_dict(hgraphs, hlayer_names)

#%%
Esempio n. 17
0
def readgraph(x):
    #Function to read from .graphml files.
    #Input: Route of the graph file.
    #Output: Object of type graph.
    g = Graph.Read_GraphML(x)
    return g
Esempio n. 18
0
def load_from_graphml(filename):
    '''Load a GraphML representation of a concept scheme'''
    g = Graph.Read_GraphML(filename)
    return g
Esempio n. 19
0
    def search_final_results_between(self, search_res1, search_res2, company_id, doc_id):
        graph_path = "/root/databuilder_train_ui/tenkTraining/Data_Builder_Training_Copy/pysrc/graphlbv/tablets_"+str(company_id)+"/"+str(doc_id)+"/" 
        fname_dict = {}
        for search_elm in search_res1:
            search_elm_sp = search_elm.split('#')
            hkeycol = search_elm_sp[0]+'#'+search_elm_sp[1]
            fname = search_elm_sp[2]
            if fname not in fname_dict:
               fname_dict[fname] = []   
            fname_dict[fname].append(hkeycol)

        #print fname_dict   

        fname_dict2 = {}
        for search_elm in search_res2:
            search_elm_sp = search_elm.split('#')
            hkeycol = search_elm_sp[0]+'#'+search_elm_sp[1]
            fname = search_elm_sp[2]
            if fname not in fname_dict2:
               fname_dict2[fname] = []   
            fname_dict2[fname].append(hkeycol)

        #print fname_dict2
 
        results_f = {}
        for fname, vs in fname_dict.items():
            ar = fname.split('_') 
            new_ar = ar[:1] + [ 'FORMULA' ] + ar[1:] 
            gpath = graph_path + '_'.join(new_ar)
            G = Graph.Read_GraphML(gpath)
            all_formula_vs = G.vs.select(lambda v:v["hashkeycol"] in vs) #graph.vs.select(lambda vertex: vertex.index % 2 == 1)
            if 'RAW' in '_'.join(ar[1:]):
               sfname = 'RAW' 
            elif 'REP' in '_'.join(ar[1:]):
               sfname = 'REP' 
            elif 'RES' in '_'.join(ar[1:]):
               sfname = 'RES' 
            if sfname not in results_f:
               results_f[sfname] = {}
            for sh_v in all_formula_vs:
                #print ' -- ', sh_v  
                fid = sh_v['fid']
                rid = sh_v['rid']
                fname = sh_v['filenames']
                k = fname.split('_')[0] 
                if k+'_'+fid+'_'+rid not in results_f[sfname]:
                   results_f[sfname][k+'_'+fid+'_'+rid] = []
                results_f[sfname][k+'_'+fid+'_'+rid].append(sh_v['ID']+'#'+ sh_v['colid']+'@'+fname)
            del G



        results2_f = {}
        for fname, vs in fname_dict2.items():
            ar = fname.split('_') 
            new_ar = ar[:1] + [ 'FORMULA' ] + ar[1:]
            gpath = graph_path + '_'.join(new_ar)
            G = Graph.Read_GraphML(gpath)
            all_formula_vs = G.vs.select(lambda v:v["hashkeycol"] in vs) #graph.vs.select(lambda vertex: vertex.index % 2 == 1)
            if 'RAW' in '_'.join(ar[1:]):
               sfname = 'RAW' 
            elif 'REP' in '_'.join(ar[1:]):
               sfname = 'REP' 
            elif 'RES' in '_'.join(ar[1:]):
               sfname = 'RES'
            if sfname not in results2_f:
               results2_f[sfname] = {}
            for sh_v in all_formula_vs:
                fid = sh_v['fid']
                rid = sh_v['rid']
                fname = sh_v['filenames']
                k = fname.split('_')[0] 
                if k+'_'+fid+'_'+rid not in results2_f[sfname]:
                   results2_f[sfname][k+'_'+fid+'_'+rid] = []
                results2_f[sfname][k+'_'+fid+'_'+rid].append(sh_v['ID']+'#'+ sh_v['colid']+'@'+fname)
            del G


        #print ' results_f: ', results_f
        #print ' results2_f: ', results2_f 

        all_results = []
        for sfname , fids1_dict in results_f.items():
            fids2_dict = results2_f[sfname]
            fname = graph_path + sfname+'ADJF.graphml' 

            shortest_paths = {}
            G = Graph.Read_GraphML(fname)

            #print fname
            fids1 = fids1_dict.keys()
            fids2 = fids2_dict.keys()
            filename_map_ddict = {}            

            all_temp_short = []
            all_temp_short_n = []
            for s in fids1:
                for d in fids2:
                    res = G.get_shortest_paths(s, to=d, output='vpath')
                    #print s, d, res 
                    for n in res: 
                           if not n: continue
                           temp_short = eval("{}".format(G.vs[n]['name']))
                           all_temp_short.append(temp_short[:])
                           all_temp_short_n.append(n)

            if all_temp_short:
                       del_inds = []
                       for i1, elm1 in enumerate(all_temp_short):
                           s1 = set(elm1)
                           for i2, elm2 in enumerate(all_temp_short):
                               s2 = set(elm2) 
                               if (i1 == i2): continue
                               if (s1 != s2) and (s1.issubset(s2)):
                                  del_inds.append(i2)  

                       #print del_inds
                       #sys.exit()  

                       for temp_ind, temp_short in enumerate(all_temp_short):

                           #print 'temp_short: ', temp_short  
                           if temp_ind in del_inds: continue
                           n = all_temp_short_n[temp_ind]
                           
                           s = temp_short[0]
                           d = temp_short[-1]    

                           fname_dict1 = {}
                           for elm in fids1_dict[s]:
                               if elm.split('@')[1] not in fname_dict1:
                                  fname_dict1[elm.split('@')[1]] = []   
                               fname_dict1[elm.split('@')[1]].append(elm.split('@')[0])
                            

                           fname_dict2 = {}
                           for elm in fids2_dict[d]:
                               if elm.split('@')[1] not in fname_dict2:
                                  fname_dict2[elm.split('@')[1]] = []   
                               fname_dict2[elm.split('@')[1]].append(elm.split('@')[0])
                            

                           highlight1 = []
                           for fname, hcols in fname_dict1.items():
                               Gdata = Graph.Read_GraphML(graph_path + fname)
                               ms = Gdata.vs.select(lambda v:v["hashkeycol"] in hcols)
                               for m in ms:
                                   highlight1.append((m["table_types"], m["grp_id"], m["row_taxo_id"], m["col"]))
                               del Gdata   

                           highlight2 = []
                           for fname, hcols in fname_dict2.items():
                               Gdata = Graph.Read_GraphML(graph_path + fname)
                               ms = Gdata.vs.select(lambda v:v["hashkeycol"] in hcols)
                               for m in ms:
                                   highlight2.append((m["table_types"], m["grp_id"], m["row_taxo_id"], m["col"]))
                               del Gdata   
                           
                           fname_dict = {} 
                           for i in range(1, len(n)):
                               int_str =  G.es[G.get_eid(n[i-1], n[i])]['intersection']
                               for elm in int_str.split(':@:'):
                                   filename, abs_key, line_key, colid, hashkey = elm.split('#')
                                   if filename not in filename_map_ddict:
                                      filename_map_ddict[filename] = {}

                                   if (s, d) not in filename_map_ddict[filename]:
                                      filename_map_ddict[filename][(s, d)] = {}
                                   if (temp_short[i-1], temp_short[i]) not in filename_map_ddict[filename][(s, d)]: 
                                      filename_map_ddict[filename][(s, d)][(temp_short[i-1], temp_short[i])] = []
                                   filename_map_ddict[filename][(s, d)][(temp_short[i-1], temp_short[i])].append(hashkey+'#'+colid)

                                   if filename not in fname_dict:
                                      fname_dict[filename] = {} 
                                   fname_dict[filename][(temp_short[i-1], temp_short[i])] =  hashkey+'#'+colid 
                            
                           shortest_paths[(s, d)] =  [ temp_short, highlight1, highlight2, copy.deepcopy(fname_dict) ]
            del G                  

            for (s, d), mresults in shortest_paths.items():
                results = [ mresults[0], mresults[1], mresults[2] ]  
                ref_dict = {}
                for fname, vdict in mresults[3].items():
                    Gdata = Graph.Read_GraphML(graph_path + fname)
                    for (n1, n2), hashkeycols in vdict.items():
                        ref_dict[(n1, n2)] = []
                        ms = Gdata.vs.select(lambda v:v["hashkeycol"] in hashkeycols)
                        for m in ms:
                            ref_dict[(n1, n2)].append((m["table_types"], m["grp_id"], m["row_taxo_id"], m["col"]))
                    del Gdata  
                results.append(copy.deepcopy(ref_dict))
                all_results.append(results[:])         
        return all_results 
Esempio n. 20
0
def load_mutag_graphs():
    return tuple(Graph.Read_GraphML(path) for path in gen_mutag_graph_paths())
Esempio n. 21
0
if __name__ == "__main__":
    distanceArray = [[
        0.0, 399.0204961659515, 500.1605551425906, 220.08242757443915,
        193.98714165293202
    ],
                     [
                         399.0204961659515, 0.0, 180.81941042547544,
                         349.8545215239509, 279.9111067819685
                     ],
                     [
                         500.1605551425906, 180.81941042547544, 0.0,
                         511.2831632819867, 326.0603063650401
                     ],
                     [
                         220.08242757443915, 349.8545215239509,
                         511.2831632819867, 0.0, 319.96901844482437
                     ],
                     [
                         193.98714165293202, 279.9111067819685,
                         326.0603063650401, 319.96901844482437, 0.0
                     ]]

    points = [[284.1169128417969, 675.3806762695312],
              [380.3543701171875, 288.1395263671875],
              [558.5081787109375, 257.2060546875],
              [123.1483154296875, 525.2960815429688],
              [441.0755920410156, 561.3851318359375]]
    fileName = GetGraphmlFile(distanceArray=distanceArray, points=points)
    pointsGraph = Graph.Read_GraphML(fileName)  # 读取文件,生成图网络
    print fileName
Esempio n. 22
0
def make_test_sim():
    import covasim as cv
    from igraph import Graph
    import sciris as sc
    import os
    import bu_covid as bu

    # Location of classroom networks
    net_dir = '../../../Data/networks'
    # Location of housing networks
    hnet_dir = '../../../Data/networks'
    # Location of pop_info.csv
    pop_info_path = '../../../Data/input/pop_info.csv'

    # Name of this simulation for output files:
    sim_name = 'testing'

    #%%
    # =============================================================================
    #  Build class networks
    # =============================================================================
    class_files = [
        'ClassNetPlatoonU.graphml',
        'ClassNetPlatoonM.graphml',
        'ClassNetPlatoonT.graphml',
        'ClassNetPlatoonW.graphml',
        'ClassNetPlatoonR.graphml',
        'ClassNetPlatoonF.graphml',
        'ClassNetPlatoonS.graphml',
    ]
    graphs = [
        Graph.Read_GraphML(os.path.join(net_dir, cf)) for cf in class_files
    ]

    class_layer_names = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']
    class_contacts = bu.get_all_class_contacts_dicts(graphs, class_layer_names,
                                                     3)

    #%%
    # =============================================================================
    #  Build housing networks
    # =============================================================================
    h_files = [
        'RoomNet.graphml', 'HouseholdNet_10.graphml', 'FloorNet.graphml'
    ]
    hgraphs = [
        Graph.Read_GraphML(os.path.join(hnet_dir, hf)) for hf in h_files
    ]

    hlayer_names = ['roommate', 'household', 'floor']
    household_contacts = bu.get_all_housing_contacts_dict(
        hgraphs, hlayer_names)

    #%%
    # =============================================================================
    #  Build BU population dictionary
    # =============================================================================
    # Use net_dir to load the all_age.txt and all_sex.txt files
    people_lut = bu.load_people_info(pop_info_path)
    BU_pop = bu.gen_BU_pop2(people_lut, class_contacts, household_contacts)

    # Run 1 day interventions by default
    start_day = '2020-01-01'
    end_day = '2020-01-02'

    # Total number of simulation days
    num_days = (bu.make_dt(end_day) - bu.make_dt(start_day)).days

    # The population size
    pop_size = BU_pop['uid'].shape[0]

    beta_val = 0.02

    # Set the quarantine and isolation beta multipliers
    quar_factor = {}
    iso_factor = {}
    for key in {**household_contacts, **class_contacts}:
        quar_factor[key] = 0.0
        iso_factor[key] = 0.0

    # Set up simulation parameters.  Get the pop size from the number of
    # vertices in any of the graphs (they're all the same)
    pars = dict(
        pop_size=pop_size,
        pop_infected=0,  # Initial number of infected people
        beta=beta_val,  # Base transmission rate
        start_day=start_day,
        end_day=end_day,
        quar_factor=quar_factor,
        iso_factor=iso_factor,
        asymp_factor=0.5,
        n_imports=0)  # n_imports - average spontaneous infections per day.

    return pars, BU_pop
Esempio n. 23
0
def multilevel_community(fin):
    H = Graph.Read_GraphML(fin)
    vc = H.community_multilevel(weights='wnorm')
    H.vs['cluster'] = vc.membership
    d = dict([(v['id'], int(v['cluster'])) for v in H.vs])
    return d