Esempio n. 1
0
    def draw_pajek():
        msgBox = QMessageBox(QApplication.activeWindow())
        msgBox.setText("Plot network with Pajek")
        msgBox.setInformativeText("Which network would you like to plot?")
        net_plot = msgBox.addButton("Network", QMessageBox.ActionRole)
        mst_plot = msgBox.addButton("MST of Network", QMessageBox.ActionRole)
        plot = True
        if Data.network.mst == None:
            msgBox.removeButton(msgBox.buttons()[1])
        msgBox.addButton(QMessageBox.Cancel)
        msgBox.exec_()
        if msgBox.clickedButton() == net_plot:
            to_plot = Data.network
            print("Plotting network with Pajek...")
        elif msgBox.clickedButton() == mst_plot:
            to_plot = Data.network.mst
            print("Plotting MST with Pajek...")
        else:
            plot = False
            print("Cancel")

        if plot:
            pajek_path = os.getcwd() + '\Pajek64\Pajek.exe'
            try:
                path, _ = QFileDialog().getSaveFileName(
                    QApplication.activeWindow(), filter='*.net')
                Network.print_pajek_network(plot_net=to_plot, sFileName=path)
                QMessageBox.information(
                    NetworkTabController.ui, "Info", "Save Success\nMap "
                    "was successfully saved to path")
            except ():
                QMessageBox.information(NetworkTabController.ui, "Warning",
                                        "Save Failed\nAn error has occurred!")

            NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                f"Network was exported to Pajek format successfully"
                f"\n\t#Nodes: {len(to_plot.nodes)}"
                f"\n\t#Edges: {len(to_plot.edges)}"
                f"\n\tNetwork save path: {path}\n")

            subprocess.Popen([pajek_path, path])
Esempio n. 2
0
 def build_network():
     QMessageBox.information(
         NetworkTabController.ui, "Notice",
         "Please note, markers with no alleles data will not be included in the network."
     )
     net = Network(
         nodes=[],
         edges=[],
         mst=None,
         skeleton=None,
         cutoff=float(
             NetworkTabController.ui.cutoff_textfield.toPlainText()))
     selected_linkages_ids = NetworkTabController.linkages_comboBox.get_selected(
     )
     NetworkTabController.ui.log_plainTextEdit.clear()
     NetworkTabController.ui.log_plainTextEdit.insertPlainText(
         "Building network of selected linkages...")
     NetworkTabController.ui.log_plainTextEdit.appendPlainText(
         "Selected linkages IDs: " + str(selected_linkages_ids))
     selected_linkages = list()
     print("Selected linkage groups:" + str(selected_linkages_ids))
     print(Data.linkage_groups.values())
     print(Data.linkage_groups.keys())
     for i in range(0, len(list(Data.linkage_groups)) + 1):
         if i in selected_linkages_ids:
             selected_linkages.append(
                 list(Data.linkage_groups.values())[i - 1])
     print(selected_linkages)
     net.initialize_network(
         selected_linkages,
         filterate=NetworkTabController.ui.filterate_checkBox.isChecked())
     Data.network = net
     NetworkTabController.ui.calc_mst_btn.setEnabled(True)
     NetworkTabController.ui.draw_pajek_btn.setEnabled(True)
     NetworkTabController.ui.subdivide_btn.setEnabled(True)
     total = 0
     [total := len(m.markers) + total for m in selected_linkages]
Esempio n. 3
0
def mDriver(netNum):
    mUri = "bolt://localhost:7687"
    conn = GraphDatabase.driver(uri=mUri,
                                auth=('neo4j', 'sjsu123'),
                                encrypted=False)

    print('con success!')

    networks = getNetworks('./data')

    count = 0
    for nName in networks:
        count += 1
        circles = getCircles('./data/', nName)
        features = getFeatures('./data/', nName)
        users = getUsers('./data/', nName, features)
        edges = getEdges('./data/', nName)

        #todo: inser user's feature array into db
        mNetwork = Network(nName, circles, users)

        #insert all into graphdb
        with conn.session() as session:
            session.write_transaction(_create_network, mNetwork)

            for cir in circles:
                session.write_transaction(_create_circle, nName, cir)

            for usr in users:
                session.write_transaction(_create_user, nName, usr)

            driver(session, mNetwork, circles, users, edges)

        if (count == netNum):
            exit(0)
    conn.close()
Esempio n. 4
0
def Main():
    global lMemory
    global wrMemory

    global lNetwork
    global wrNetwork

    global lCPU
    global wrCPU

    global lDisk
    global wrDisk

    global lDisplayThread
    global Path
    global Files
    global Infected
    global currentDate

    global dGraph
    global nGraph
    global mGraph
    global cGraph
    global LoopCount
    global LoopsAllowed

    try:
        currentDate = '{0:%Y-%m-%d-%H-%M-%S}'.format(datetime.datetime.now())

        # Setting up Memory and Memory Writer
        lMemory = Memory()
        infected = "Infected" if Infected is True else "Not-Infected"
        wrMemory = Writer(Path + "\\CSV\\Memory\\" + infected + "\\", "Memory",
                          None, currentDate)
        # Setting up CPU and CPUs Writer
        lCPU = CPU()
        wrCPU = Writer(Path + "\\CSV\\CPU\\" + infected + "\\", "CPU", None,
                       currentDate)
        # Setting up Disks and Disks Writer
        lDisk = Disks()
        wrDisk = Writer(Path + "\\CSV\\Disks\\" + infected + "\\", "Disk",
                        None, currentDate)
        # Setting up Network and Networks Writer
        lNetwork = Network()
        wrNetwork = Writer(Path + "\\CSV\\Network\\" + infected + "\\",
                           "Network", None, currentDate)

        LoopsAllowed = options.opt_loops
        LoopCount = 0
        # Setting up graph objects
        if options.opt_graph is True:
            dGraph = Graph(Disks, "Time", "Value", "Disk Performance", True)
            nGraph = Graph(Network, "Time", "Value", "Network Performance",
                           True)
            mGraph = Graph(Memory, "Time", "Value", "Memory Performance", True)
            cGraph = Graph(CPU, "Time", "Value", "CPU Performance", True)

        # Setting up the display thread
        lDisplayThread = RepeatedTimer(1, Display)
    except Exception as ex:
        print(ex)

    while True:
        time.sleep(1000)
    return
Esempio n. 5
0
import time
import json
from flask import Flask, request
import requests

from classes.Blockchain import Blockchain
from classes.Network import Network
from classes.Wallet import Wallet

app = Flask(__name__)

# the node's copy of blockchain
blockchain = Blockchain()

network = Network()


# endpoint to submit a new transaction. This will be used by
# our application to add new data (posts) to the blockchain
@app.route('/new_transaction', methods=['POST'])
def new_transaction():
    tx_data = request.get_json()
    required_fields = ["from", "amount", "to"]

    for field in required_fields:
        if not tx_data.get(field):
            return "Invalid transaction data", 404

    tx_data["amount"] = int(tx_data["amount"])

    if tx_data["amount"] < 0:
Esempio n. 6
0
         [3, "Exit", "exit"]]))
MENUS.append(
    Menu("Settings", "Customize your game settings below",
         [[1, "Enable Debug", "debug"], [2, "Show Help", "help"],
          [3, "Back", "back"]]))
MENUS.append(
    Menu(
        "Play",
        "Welcome to your terminal. Select from the options below to get started",
        [[1, "Jobs Board", "jobs"], [2, "Banking", "bank"], [
            3, "Shop", "shop"
        ], [4, "Terminal", "terminal"], [5, "Logout", "logout"]]))

# Network List
NETWORKS.append(
    Network("10MB Network Card", "Basic Network Card", 100, 1, 10, 10))
NETWORKS.append(
    Network("100MB Network Card", "Standard Network Card", 1000, 1, 100, 100))
NETWORKS.append(
    Network("1GB Network Card", "Advanced Network Card", 10000, 1, 1000, 1000))
NETWORKS.append(
    Network("10GB Network Card", "High Speed Network Card", 100000, 2, 10000,
            10000))

# Processor List
PROCESSORS.append(
    Processor("Insmell PC2000", "Basic Consumer Processor", 100, 1, 2000))
PROCESSORS.append(
    Processor("Insmell PC3000", "Standard Consumer Processor", 300, 1, 3000))
PROCESSORS.append(
    Processor("Insmell PC4000", "Standard Consumer Processor w/ Turbo", 600, 1,
Esempio n. 7
0
#%%
from matplotlib import pyplot as plt
from classes.Network import Network as Net
from torch.utils.data import DataLoader as DataLoader
from torchvision import datasets, transforms
from torch import nn, optim

#%%
guess_mode = True
continue_training = False
training = not guess_mode
training_validation = False

#%%
network = Net(1, 2, 2)
network = network.cuda()

#%%
transform_in = transforms.Compose([
    transforms.Resize((72, 128)),
    transforms.Grayscale(),
    transforms.ToTensor()
])

transform_out = transforms.Compose([
    transforms.Resize((72, 128)),
    transforms.ToTensor()
])

#%%
Esempio n. 8
0
    def subdivide_network():
        val, ok = QInputDialog.getDouble(
            QApplication.activeWindow(),
            "Parallel cutoff",
            "Input cutoff value for unproven parallel linkages",
            0.25,
            0.0,
            1.0,
            decimals=3,
            step=0.01)
        if ok:
            NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                f"Testing network for linear structure...")

            linear_net, excluded = Data.network.makeLinearContigClusters(
                bExcludeNodesCausingNonLinearClusters=True,
                cutoff=float(
                    NetworkTabController.ui.cutoff_textfield.toPlainText()),
                cutoffParallel=float(val))

            if len(excluded) != 0:
                NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                    f"{len(Data.network.nodes) - len(linear_net.nodes)} nodes were removed:"
                )

                excluded = [
                    str(str(id) + "\t" + Data.network.nodes[id].caption)
                    for id in excluded
                ]
                for ex in excluded:
                    NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                        ex)

                pajek_path = os.getcwd() + '\Pajek64\Pajek.exe'
                try:
                    path, _ = QFileDialog().getSaveFileName(
                        QApplication.activeWindow(), filter='*.net')
                    Network.print_pajek_network(plot_net=linear_net,
                                                sFileName=path)
                    QMessageBox.information(
                        NetworkTabController.ui, "Info", "Save Success\nMap "
                        "was successfully saved to path")
                except ():
                    QMessageBox.information(
                        NetworkTabController.ui, "Warning",
                        "Save Failed\nAn error has occurred!")
                NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                    f"Linear structure network was built successfully!"
                    f"\n\t#Nodes: {len(linear_net.nodes)}"
                    f"\n\t#Edges: {len(linear_net.edges)}\n")

                QMessageBox.information(
                    NetworkTabController.ui, "Notice",
                    "Network was subdivided into linear components successfully!"
                )
                subprocess.Popen([pajek_path, path])
            else:
                QMessageBox.information(
                    NetworkTabController.ui, "Notice",
                    "Network is already linearly structured!")
                NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                    "\tNetwork is already linearly structured!\n")