Commit 419b3ecc authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

bugfix: correct filtering ; verbose: add verbose to parallel jobs

parent 0ff34ba2
......@@ -2,19 +2,32 @@ import networkx as nx
from abc import abstractmethod
from multiprocessing import Pool, Value
from deconvolution.dgraph.FixedDGIndex import FixedDGIndex
from deconvolution.dgraph.FixedDGIndex import FixedDGIndex, AbstractDGIndex
counter = None
def process_node(factory, node):
global counter
my_value = counter.value
counter.value += 1
if factory.verbose:
print(f"{my_value}: Generating d-graphs")
# udg generation
neighbors = list(factory.graph.neighbors(node))
subgraph = nx.Graph(factory.graph.subgraph(neighbors))
dgs = factory.generate_by_node(node, subgraph)
global counter
counter.value += 1
if factory.verbose:
print(f"\r{counter.value}/{factory.nb_nodes} node analysis", end='')
print(f"{my_value}: d-graphs generated, starting filtering")
print(f"{my_value}: {len(dgs)} graphs to filter")
# udg domination filtering
dgs = AbstractDGIndex.filter_entry(dgs)
if factory.verbose:
print(f"{my_value}({factory.nb_nodes}) terminated")
return node, dgs
......@@ -34,6 +47,9 @@ class AbstractDGFactory:
global counter
counter = Value('i', 0)
if verbose:
print("Start parallel work")
results = None
with Pool(processes=threads) as pool:
results = pool.starmap(process_node, zip(
......@@ -77,6 +77,4 @@ class CliqueDGFactory(AbstractDGFactory):
d_graph.put_halves(clq1, clq2, subgraph)
# Filter dominated
node_d_graphs = AbstractDGIndex.filter_entry(node_d_graphs)
return node_d_graphs
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment