Skip to content

Commit 76105da

Browse files
committed
fixup! fixup! WIP
1 parent c53a278 commit 76105da

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/app/view/editor-tools-view-component/editor-tools-view.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,26 +512,27 @@ export class EditorToolsViewComponent {
512512
headers.push($localize`:@@app.view.editor-side-view.editor-tools-view-component.connections:Connections`);
513513
headers.push($localize`:@@app.view.editor-side-view.editor-tools-view-component.totalCost:Total cost`);
514514

515+
const nodes = this.nodeService.getNodes();
515516
const selectedNodes = this.nodeService.getSelectedNodes();
516-
const nodes = selectedNodes.length > 0 ? selectedNodes : this.nodeService.getVisibleNodes();
517+
const odNodes = selectedNodes.length > 0 ? selectedNodes : this.nodeService.getVisibleNodes();
517518
const trainruns = this.trainrunService.getVisibleTrainruns();
518519

519-
const edges = buildEdges(nodes, trainruns, connectionPenalty, this.trainrunService, timeLimit);
520+
const edges = buildEdges(nodes, odNodes, trainruns, connectionPenalty, this.trainrunService, timeLimit);
520521

521522
const neighbors = computeNeighbors(edges);
522523
const vertices = topoSort(neighbors);
523524
// In theory we could parallelize the pathfindings, but the overhead might be too big.
524525
const res = new Map<string, [number, number]>();
525-
nodes.forEach((origin) => {
526+
odNodes.forEach((origin) => {
526527
computeShortestPaths(origin.getId(), neighbors, vertices).forEach((value, key) => {
527528
res.set([origin.getId(), key].join(","), value);
528529
});
529530
});
530531

531532
const rows = [];
532-
nodes.sort((a, b) => a.getFullName().localeCompare(b.getFullName()));
533-
nodes.forEach((origin) => {
534-
nodes.forEach((destination) => {
533+
odNodes.sort((a, b) => a.getFullName().localeCompare(b.getFullName()));
534+
odNodes.forEach((origin) => {
535+
odNodes.forEach((destination) => {
535536
const costs = res.get([origin.getId(), destination.getId()].join(","));
536537
if (costs === undefined) {
537538
// Keep empty if no path is found.

src/app/view/util/origin-destination-graph.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Edge {
2727
){}
2828
}
2929

30-
export const buildEdges = (nodes: Node[], trainruns: Trainrun[], connectionPenalty: number, trainrunService: TrainrunService,
30+
export const buildEdges = (nodes: Node[], odNodes: Node[], trainruns: Trainrun[], connectionPenalty: number, trainrunService: TrainrunService,
3131
timeLimit: number
3232
): Edge[] => {
3333
let edges = buildSectionEdges(trainruns, trainrunService, timeLimit);
@@ -59,7 +59,7 @@ export const buildEdges = (nodes: Node[], trainruns: Trainrun[], connectionPenal
5959
});
6060

6161
// Note: pushing too many elements at once does not work well.
62-
edges = [...edges, ...buildConvenienceEdges(nodes, verticesDepartureByNode, verticesArrivalByNode)];
62+
edges = [...edges, ...buildConvenienceEdges(odNodes, verticesDepartureByNode, verticesArrivalByNode)];
6363
edges = [...edges, ...buildConnectionEdges(nodes, verticesDepartureByNode, verticesArrivalByNode, connectionPenalty)];
6464

6565
return edges;

src/integration-testing/origin.destination.csv.test.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe("Origin Destination CSV Test", () => {
8080
const connectionPenalty = 5;
8181
const timeLimit = 60*10;
8282

83-
const edges = buildEdges(nodes, trainruns, connectionPenalty, trainrunService, timeLimit);
83+
const edges = buildEdges(nodes, nodes, trainruns, connectionPenalty, trainrunService, timeLimit);
8484

8585
const neighbors = computeNeighbors(edges);
8686
const vertices = topoSort(neighbors);

0 commit comments

Comments
 (0)