Revision 1ef4948a simulator.py

View differences:

simulator.py
10 10

  
11 11
import networkx as nx
12 12
import util.MyUtil as myu
13
import util.nx2gt as nx2gt
13 14
from time import sleep
14 15
import matplotlib.pyplot as plt
15 16
plt.ion()
......
45 46

  
46 47
                if self.gui:
47 48
                    self.draw(G, positions)
48
                stats = ['BC', 'LC', 'DEG']
49
                #stats = ['BC', 'LC', 'DEG']
50
                stats = ['BC']
49 51

  
50 52
                self.logStatistics(G, stats, sched.processed_events())
51 53
                # schedule next DV
......
58 60
        tag = '%08d' % tag
59 61
        for stat in whatLog:
60 62
            if stat == 'BC':
61
                bw_centrality = nx.betweenness_centrality(
62
                    G, normalized=False,  weight='weight', endpoints=True)
63
                df = pd.DataFrame(bw_centrality.items(),
64
                                  columns=['Node', 'BC'])
63
                '''bw_centrality = nx.betweenness_centrality(G, normalized=False,  weight='weight', endpoints=True)'''
64
                #code.interact(local=dict(globals(), **locals()))
65
                import graph_tool.centrality as gtc
66
                gtG = nx2gt.nx2gt(G)
67
                ws=gtG.edge_properties["weight"]
68
                vp, ep = gtc.betweenness(gtG, norm=False, weight=ws)
69
                btw = {i: vp.a[i] for i in range(len(vp.a))}
70
                df = pd.DataFrame(btw.items(), columns=['Node', 'BC'])
65 71
                df.to_csv(self.OP+"/BC"+tag+".csv", sep=',',
66 72
                          encoding='utf-8', index=False)
67 73
            if stat == 'LC':

Also available in: Unified diff