Skip to content

Commit b00aa85

Browse files
committed
Improvements/fixes
1 parent 28b5e4e commit b00aa85

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ When it completes, load `file:///path-to-your-checkout/react-workflow-viz/index.
2222
## Changelog
2323
_Side Note -_ Is there a way to auto-generate a `CHANGELOG.md` file out of releases' content?
2424

25+
#### 2020-01-21
26+
- Important glitch fixes, including typo and intersection counting.
27+
- PROTOTYPE / NOT ENABLED: Reuse horizontal edge segments (to reduce # of lines; noise) if:
28+
- Segment is on same Y coordinate as previous segment (or source node, if first segment) _and_ has common source node. This prevents a path from a single node from prematuraly splitting into many separate paths.
29+
- Segment is leading to a common target node. This allows paths to converge if beneficial.
30+
- This could be better tested; perhaps reused segments should be treated differently in regard to intersections (at least excluded).
31+
2532
#### 2019-10-06
2633

2734
- Improved ordering of terminal reference file input nodes.

src/components/EdgesLayer.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function traceEdges(
102102
let closestSegmentDiff = Infinity;
103103
let closestSegmentIdx = -1;
104104
let currSegment = null, currSegmentY = 0, currExistingSegmentNodes = null, currDiff = null;
105-
let i, j, prevEdge, prevVs, intersections = 0;
105+
let i, j, prevEdge, prevVs, multiplier = 1, intersections = 0;
106106
for (i = 0; i < segmentQLen; i++){
107107
currSegment = segmentQ[i];
108108
currSegmentY = currSegment[0][1];
@@ -114,17 +114,22 @@ export function traceEdges(
114114
// Skip used segments unless (going to same target node) or (from same source node and on same Y coord).
115115
currExistingSegmentNodes = usedSegments.get(currSegment);
116116
if (currExistingSegmentNodes){
117-
if (!(currExistingSegmentNodes[1] === target || (currExistingSegmentNodes[0] === source && currSegmentY === prevYCoord))){
118-
continue;
119-
}
117+
continue;
118+
// Use below for experiment with converging / shared path for common source/target nodes.
119+
// if (!(currExistingSegmentNodes[1] === target || (currExistingSegmentNodes[0] === source && currSegmentY === prevYCoord))){
120+
// continue;
121+
// }
120122
}
121123

122124
//currDiff = Math.abs(yCoordMedian - currSegmentY);
123125
if (currSegmentY > upperY){
124126
currDiff = currSegmentY - upperY;
125127
} else if (currSegmentY < lowerY){
126128
currDiff = lowerY - currSegmentY;
129+
} else if (currExistingSegmentNodes) {
130+
currDiff = -0.01;
127131
} else {
132+
//{
128133
// Any path between lower and upper bound is fine.
129134
// Favor those closer to prev edge
130135
//currDiff = Math.abs(targetYCoord - currSegmentY) * 0.01;
@@ -137,24 +142,33 @@ export function traceEdges(
137142
prevEdge = previousEdges[j];
138143
if (Array.isArray(prevEdge.vertices)){
139144
prevVs = prevEdge.vertices;
145+
multiplier = 2;
140146
} else {
141147
prevVs = [
142148
[ prevEdge.source.x + columnWidth, prevEdge.source.y ],
143149
[ prevEdge.target.x, prevEdge.target.y ]
144150
];
151+
multiplier = 1;
145152
}
146153

147154
prevVs.reduce(function(prevV, v){
148155
if (!prevV) return v; // First V
149-
if (!(prevV[0] + nodeEdgeLedgeWidths[0] < startXForCol && v[0] >= startXForCol)){
156+
157+
if (!(prevV[0] + nodeEdgeLedgeWidths[0] < startXForCol && v[0] >= startXForCol - nodeEdgeLedgeWidths[0])){
150158
return v;
151159
}
160+
// if (source.name === "chromsize" && columnIdx === 2) {
161+
// console.log('TTTX\n', v, '\n', prevV, '\n', columnIdx, intersections);
162+
// }
152163
if (
153164
(v[1] > currSegmentY && prevV[1] < prevYCoord) ||
154165
(v[1] < currSegmentY && prevV[1] > prevYCoord)
155166
) {
156-
if (intersections === 0) intersections += 2;
157-
intersections++;
167+
// Boost 'any' intersections
168+
// Multiplier allows us to try to avoid intersecting
169+
// bigger lines moreso than smaller ones
170+
if (intersections === 0) intersections += 2 * multiplier;
171+
intersections += multiplier;
158172
//if (startXForCol> 1400 && startXForCol < 1600){
159173
// console.log('X', v[0], v[1], '<-', prevV[0], prevV[1]);
160174
//}
@@ -164,6 +178,10 @@ export function traceEdges(
164178

165179
}
166180

181+
// if (source.name === "chromsize" && columnIdx === 2) {
182+
// console.log('TTT', previousEdges.slice(), columnIdx, currSegmentY, intersections);
183+
// }
184+
167185
currDiff += (intersections * (rowSpacing * 0.8));
168186

169187
//if (startXForCol> 1400 && startXForCol < 1600){
@@ -192,8 +210,8 @@ export function traceEdges(
192210
const originalEdgesSortedByLength = originalEdges.slice(0).sort(function(edgeA, edgeB){
193211
const { source: sA, target: tA } = edgeA;
194212
const { source: sB, target: tB } = edgeB;
195-
const colDifA = Math.abs(tA.colum - sA.column);
196-
const colDifB = Math.abs(tB.colum - sB.column);
213+
const colDifA = Math.abs(tA.column - sA.column);
214+
const colDifB = Math.abs(tB.column - sB.column);
197215

198216
// If just 1 col dif, move to front for intersection testing (tracing skipped)
199217
if (colDifA === 1 && colDifB === 1){
@@ -216,8 +234,8 @@ export function traceEdges(
216234
const yDistA = Math.abs(tA.y - sA.y);
217235
const yDistB = Math.abs(tB.y - sB.y);
218236

219-
if (yDistA < yDistB) return -1;
220-
if (yDistA > yDistB) return 1;
237+
if (yDistA > yDistB) return -1;
238+
if (yDistA < yDistB) return 1;
221239

222240
return 0;
223241
});

0 commit comments

Comments
 (0)