Skip to content

Commit 38599a5

Browse files
committed
Small optimizations. I hope.
1 parent c4ecc98 commit 38599a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cfpq_add_context/add_contexts.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def transitive_reduction(assigns, vertices_with_other_edges):
4646
filter(~x.S) << endpoints
4747

4848
#print("Filter: ", filter)
49-
to_result = Matrix(BOOL, assigns.ncols, assigns.ncols, name = "to_result")
50-
to_result << (Matrix.mxm(new_frontier, filter, "any_pair"))
49+
#to_result = Matrix(BOOL, assigns.ncols, assigns.ncols, name = "to_result")
50+
#to_result << (Matrix.mxm(new_frontier, filter, "any_pair"))
5151
#print("To result: ", to_result)
5252

53-
result("any") << to_result
53+
result("any") << (Matrix.mxm(new_frontier, filter, "any_pair"))
5454

5555
print ("Result nvals = ", result.nvals)
5656

@@ -194,12 +194,14 @@ def add_context(file_path, max_num_of_contexts):
194194

195195
return (decomposed_result, graph.ncols)
196196

197+
197198
def normalize(solver_result, initial_graph_nvertices):
198199

199200
normalization_start = time.perf_counter()
200201

201202
atm_size = solver_result.ncols // initial_graph_nvertices
202203
start_vertices = set([i * atm_size for i in range(0,initial_graph_nvertices)])
204+
solver_result.Select(lambda (x,i,j,k): i % atm_size == 0)
203205
edges = solver_result.to_edgelist()
204206
edges = zip(edges[0], edges[1])
205207
new_edges = set([(_edg[0] // atm_size, _edg[1] // atm_size) for (_edg, _lbl) in edges if _edg[0] in start_vertices])

0 commit comments

Comments
 (0)