Commit f75e2095 authored by Yoann Dufresne's avatar Yoann Dufresne
Browse files

time optimization for evaluate method

parent 956c8710
......@@ -180,7 +180,7 @@ def print_dgraphs_summary(frequencies, light_print=False):
def str_to_udg_lists(s):
udg = s.replace("]", "").replace(' [', '[')
return udg.split('[')
return udg.split('[')[1:]
def parse_dg_name(gr, name):
udg = nx.get_node_attributes(gr, 'udg')[name]
......@@ -247,20 +247,24 @@ def print_d2_summary(connected_components, longest_path, covered_vars={}, light_
def compute_next_nodes(d2_component):
# First parse dg names
dg_names = {}
for node in d2_component.nodes():
dg_names[node] = parse_dg_name(d2_component,node)
next_nodes = {}
for node in d2_component.nodes():
# Parse the current node name
head, h1, h2 = parse_dg_name(d2_component,node)
head, h1, h2 = dg_names[node]
next_nodes[node] = {}
neighbors = list(d2_component.neighbors(node))
# Get the current molecule idxs
molecule_idxs = mols_from_node(head[1])
for mol_idx in molecule_idxs:
nexts = []
for neighbor in neighbors:
nei_head, _, _ = parse_dg_name(d2_component,neighbor)
for neighbor in d2_component[node]:
nei_head, _, _ = dg_names[neighbor]
nei_mols = mols_from_node(nei_head[1])
nei_mols = [x for x in nei_mols if x > mol_idx]
......@@ -406,7 +410,7 @@ def verify_graph_edges(d2_component):
for c in [c1,c2]:
for c_node in c:
nei_mols = mols_from_node(c_node.split()[0])
nei_mols = [x for x in nei_mols if x > mol_idx] # fixme: also look at the <= molecules for more robustness
nei_mols = [x for x in nei_mols if x > mol_idx] # fixme: also look at the <= molecules for more robustness
# If there are molecule next
if len(nei_mols) > 0:
......
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