Open samblau opened 3 years ago
I expect @KhanWhale may take the first crack at modifying the code to fix this issue since @hpatel1567 has a lot on her plate the next couple of weeks, but @hpatel1567 should be following along closely to make sure she understands and agrees with all changes being made.
Most recent PR #31 should be a good step in the right direction-was able to generalize graph representation, which will reduce the locations we need to tweak code, as well as elucidate the logic behind the representation in a crisper and more concise manner. Next step may be to modify the actual data stored on nodes/edges so as to simplify the algorithm as well as facilitate the removal of duplicate/redundant nodes.
While it was easiest to conceptualize the introduction of prerequisites by any A + B -> ??? reaction node into two, A + PR_B -> ??? and B + PR_A -> ???, technically it is unnecessary since the costs are on the edges, not the nodes. Thus, we can dramatically reduce the size of our networks, which in practice are mostly composed of A + B -> ??? reactions, by replacing the two nodes A + PR_B -> ??? and B + PR_A -> ??? with a single A + B -> ??? node, where the edge from A to that reaction node will include the cost of PR_B and the edge from B to that reaction node will include the cost of PR_A. This should approximately halve the size of our networks (thus halving the amount of memory) and approximately halve the time required to solve prerequisite costs thanks to the scaling of Dijkstra's algorithm.