Beispiel #1
0
    def open_net(self, *args):
        
        filters = ['Network pickle (*.gz), (*.tar.gz)', 'All files (*)']
        selectedFilter = 'Network pickle (*.gz), (*.tar.gz)'
        filters = ';;'.join(filters)

        fname = QFileDialog.getOpenFileName(
            self, "Choose a file to open", '', filters, selectedFilter)
        
        if fname:
            try:
                print ("open " + fname)
                #self.fname = fname
                self.net = None
                self.net = read_pickle(fname)
                self.scene.draw_net(self.net)
            except Exception as e:
                #print ("Error opening file %s" % str(e)),
                QMessageBox.critical(
                    self, "Error opening file", str(e),
                    QMessageBox.Ok, QMessageBox.NoButton)
@author: admin
"""
from pymote import NetworkGenerator
from pymote.npickle import read_pickle, write_pickle
from networkx import minimum_spanning_tree, prim_mst_edges, prim_mst, spring_layout
from pymote.network import Network
from pymote.simulation import Simulation
from networkx import draw, Graph,  draw_networkx_edges, draw_networkx_edge_labels, get_node_attributes
from pylab import show, figure
import random


#from pymote.algorithms.turk2018.megamerge_p import MegaMerger
from pymote.algorithms.turk2018.megamerge import MegaMerger

test_net = net = read_pickle('RandomBezAlg.tar.gz')
#test_net = net = read_pickle('WorstCaseBezAlg.tar.gz')
net.show()


net.algorithms = (MegaMerger,)
write_pickle(net, 'RandomSAlg.tar.gz')
#write_pickle(net, 'WorstCaseSAlg.tar.gz')
##s ovom mrezom pokretati GUI simulator

g = Graph()
g.adj=net.adj

#Uses Kruskal’s algorithm.
#If the graph edges do not have a weight attribute 
#a default weight of 1 will be used.
Beispiel #3
0
from pymote.simulation import Simulation
from networkx import minimum_spanning_tree
#from pymote.algorithms.turk2018.megamerge_p import MegaMerger
from pymote.algorithms.turk2018.megamerge import MegaMerger

##RANDOM
net_gen = NetworkGenerator(3)
net = net_gen.generate_random_network()
#write_pickle(net,'mreza.tar.gz')

#graph_tree = minimum_spanning_tree(net)
#net.adj = graph_tree.adj

##READ
net = Network()
read_pickle(net, "all.tar.gz")
net.show()

net.algorithms = (MegaMerger, )

sim = Simulation(net)
sim.run()

exclude = list()
exclude.append('Neighbors')

for node in net.nodes():

    print node.id, node.status
    for key in node.memory:
        print key, ':\t', node.memory[key]
from pymote import NetworkGenerator
from pymote.npickle import read_pickle, write_pickle
from networkx import minimum_spanning_tree
#from pymote.algorithms.MegaMeger import MegaMerger
from pymote.algorithms.turk2018.megamerge_p import MegaMerger
from pymote.simulation import Simulation
from networkx import draw, Graph
from pylab import show

net = read_pickle("poslati.txt")
write_pickle(net, 'bezAlg.tar.gz')

#net.algorithms = (MegaMerger,)
#write_pickle(net, 'saAlg.txt')

g = Graph()
g.add_edge(net.nodes()[0], net.nodes()[1], weight=1)
g.add_edge(net.nodes()[0], net.nodes()[2], weight=2)
g.add_edge(net.nodes()[0], net.nodes()[5], weight=3)
g.add_edge(net.nodes()[2], net.nodes()[6], weight=4)
g.add_edge(net.nodes()[3], net.nodes()[5], weight=5)
g.add_edge(net.nodes()[4], net.nodes()[6], weight=6)
g.add_edge(net.nodes()[6], net.nodes()[7], weight=7)

#dodatni, da naprave razliku
g.add_edge(net.nodes()[3], net.nodes()[4], weight=8)
g.add_edge(net.nodes()[5], net.nodes()[7], weight=9)
g.add_edge(net.nodes()[1], net.nodes()[2], weight=10)

#draw(g)
#show()
"""
#from pymote import NetworkGenerator
from pymote.npickle import read_pickle, write_pickle
from pymote.network import Network
from pymote.simulation import Simulation
from networkx import minimum_spanning_tree, prim_mst_edges, prim_mst, draw, Graph, draw_networkx_edges, spring_layout, draw_networkx_edge_labels, draw_networkx_nodes, draw_networkx_labels
from pylab import show, figure
import random

#from pymote.algorithms.turk2018.megamerge_p import MegaMerger
from pymote.algorithms.turk2018.megamerge import MegaMerger

#test_net = read_pickle('RandomBezAlg.tar.gz')
#net = read_pickle('RandomBezAlg.tar.gz')

test_net = read_pickle('WorstCaseBezAlg.tar.gz')
net = read_pickle('WorstCaseBezAlg.tar.gz')

#test_net = read_pickle('WorstCaseBezAlg.tar.gz')
net.show()
#
figure(2)
#draw(g,pos)
# specifiy edge labels explicitly

g = Graph()
g.adj = net.adj

edge_labels = dict([((
    u,
    v,