diff --git a/src/ILP.py b/src/ILP.py index ca3b2e7..355a9dc 100644 --- a/src/ILP.py +++ b/src/ILP.py @@ -53,11 +53,11 @@ def imp(name, cond, vals): # c[i] >= 0 ===> v[i] >= 0 for e1, (s1, t1, _) in graph.edge.items(): for e2, (s2, t2, _) in graph.edge.items(): if graph.node[s1][y] > graph.node[s2][y] > graph.node[t1][y]: - # crossY = [node[t1,y] - node[s2,y] -1, node[t2,y] - node[t1,y] -1] e1GTs2 = node[s1] + edge[e1] - node[s2] + e1GTt2 = node[s1] + edge[e1] - node[t2] - m.addConstr(imp(f'R {e1} {e2}', [ edge[e1]], [ e1GTs2 -1])) - m.addConstr(imp(f'L {e1} {e2}', [-edge[e1]], [-e1GTs2 -1])) + m.addConstr(imp(f'R {e1} {e2}', [ edge[e2], e1GTs2], [ e1GTt2 -1])) + m.addConstr(imp(f'L {e1} {e2}', [-edge[e2], -e1GTs2], [-e1GTt2 -1])) # s.x > e.x > t.x for e, (s, t, _) in graph.edge.items(): tGTs = node[t] - node[s] diff --git a/src/graph.coffee b/src/graph.coffee index 33b3db4..8a539aa 100644 --- a/src/graph.coffee +++ b/src/graph.coffee @@ -128,11 +128,14 @@ readCSV = (fileNodes, fileEdges) -> e++ yield t -state = new State readCSV '../data/nodes.csv', '../data/edges.csv' +state = new State readCSV '../data/test_nodes.csv', '../data/test_edges.csv' for graph from state.iter() graph.nodes[n][0] = r for n, r of graph.ranks + for e, [s,t,o] of graph.edges + graph.edges[e] = [t,s,o] if graph.nodes[s][0] < graph.nodes[t][0] + fs.writeFileSync '../data/graphlayout.json', JSON.stringify 'edges': graph.edges 'nodes': graph.nodes diff --git a/src/main.coffee b/src/main.coffee index 862b0cd..087c48e 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -23,9 +23,9 @@ addNode = ([y, x]) -> addEdge = ([ys, xs], [yt, xt], offset) -> line1 = addLine [ys,xs], [ys,xs+offset] - line2 = addLine [yt+.5,xs+offset], [yt+.5,xt] - line3 = addLine [ys,xs+offset], [yt+.5,xs+offset] - line4 = addLine [yt+.5, xt], [yt, xt] + line2 = addLine [yt+.3,xs+offset], [yt+.3,xt] + line3 = addLine [ys,xs+offset], [yt+.3,xs+offset] + line4 = addLine [yt+.3, xt], [yt, xt] group [line1, line2, line3, line4] addLine = ([ys, xs], [yt, xt]) -> @@ -46,5 +46,4 @@ for _, pos of graph.nodes for _, pos of graph.nodes addNode pos for _, [s, t, offset] of graph.edges - [s, t] = [t, s] if graph.nodes[s][0] < graph.nodes[t][0] addEdge graph.nodes[s], graph.nodes[t], offset \ No newline at end of file