Esempio n. 1
0
File: gi.py Progetto: stablum/soa
def nodes():
    """
    returns the graph's nodes
    """
    return [ node 
             for node 
             in g().nodes 
             if node is not None 
    ]
Esempio n. 2
0
File: gi.py Progetto: stablum/soa
def edges():
    """
    returns the graph's edges
    """
    return [ e 
            for e 
            in g().edges 
            if e is not None 
            and hasattr(e,'source')
            and hasattr(e,'target')
    ]
Esempio n. 3
0
        if level is not None:
            if isinstance(level, int):
                self.level = level
            else:
                self.level = getattr(LogLevel, level)
        else:
            return level

    def log(self, level='info', show=True, **kw):
        self.queue.put(Loggable(kw, level, show))

    def run(self):
        with open(self.file_name, self.open_mode) as self.file:
            self.write_log()

    def write_log(self):
        while True:
            obj = self.queue.get()
            if obj is None or not self._run:
                break
            self.file.write(repr(obj) + '\n')
            if obj.show and obj.level > self.level:
                print(obj)

    def stop(self):
        self._run = False
        self.queue.put(None)

logger = Logger(config.local_file(config.g('log', 'file')),
                config.g('log', 'open_mode'))
logger.start()
Esempio n. 4
0
File: gi.py Progetto: stablum/soa
def kill_edge(e):
    g().underlyingGraph.readUnlockAll()
    set_weight(e, 0.0)
Esempio n. 5
0
import os

from config import d, g

os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
if __name__ == "__main__":
    dd, gg = d(), g()
    module = __import__("algorithms.%s" % d.config.algo,
                        fromlist=[d.config.algo])
    algo_class = getattr(module, d.config.algo)
    algo_class(dd, gg, eval=True)