SchweizerischeBundesbahnen / netzgrafik-editor-frontend

The Netzgrafik-Editor is a powerful software that enables the creation, modification, and analysis of regular-interval timetable.
https://schweizerischebundesbahnen.github.io/netzgrafik-editor-frontend/
Other
30 stars 10 forks source link

[Bug]: Origin/Destination Matrix - not all path are reported/found #312

Open aiAdrian opened 4 days ago

aiAdrian commented 4 days ago

Preflight Checklist

Bug type

Functionality

Which version are you using

2.8.0

Operating system

Windows 10

Browser / Browser version

Google Chrome

Input mode

None

Additional settings

No response

What happened?

The Origin-Destination Matrix is not finding all connections, i.e., routes. For example, no route is found for Bern - Biel; consequently, the entry is blank in the CSV export.

Test: https://schweizerischebundesbahnen.github.io/netzgrafik-editor-frontend/

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

Origin | Destination | Travel time | Connections | Total cost -- | -- | -- | -- | -- ...| ...|  ... |...   |   Bern | Biasca | 195 | 2 | 205 Bern | Biel |   |   |   Bern | BNWD |   |   |   ...| ...|  ... |...   |  

image The matrix shows all connection durations (if not available or = 0 => no coloring) and the number of transfers are given as text (numbers).

Steps to reproduce the issue

  1. Open https://schweizerischebundesbahnen.github.io/netzgrafik-editor-frontend/
  2. Navigate to the left menu bar, select More functions -> Netzgrafik -> Origin-Destination as CSV.
  3. Open the exported CSV file and search for Bern -> Biel.

Relevant log output

Attempting initialization Mon Oct 14 2024 16:03:40 GMT+0200 (Mitteleuropäische Sommerzeit) origin-destination-graph.ts:142 Ignoring trainrun (no root found): 85 origin-destination-graph.ts:142 Ignoring trainrun (no root found): 86 origin-destination-graph.ts:142 Ignoring trainrun (no root found): 87 origin-destination-graph.ts:142 Ignoring trainrun (no root found): 88 origin-destination-graph.ts:142 Ignoring trainrun (no root found): 89 origin-destination-graph.ts:142 Ignoring trainrun (no root found): 90

const buildSectionEdges = (trainruns: Trainrun[], trainrunService: TrainrunService, timeLimit: number): Edge[] => {
    const edges = [];
    const its = trainrunService.getRootIterators();
    trainruns.forEach((trainrun) => {
        const tsIterators = its.get(trainrun.getId());
        if (tsIterators === undefined) {
          console.log("Ignoring trainrun (no root found): ", trainrun.getId());
          return;
        }
        tsIterators.forEach((tsIterator) => {
          edges.push(...buildSectionEdgesFromIterator(tsIterator, false, timeLimit));
          const ts = tsIterator.current().trainrunSection;
          const nextIterator = trainrunService.getIterator(ts.getTargetNode(), ts);
          edges.push(...buildSectionEdgesFromIterator(nextIterator, true, timeLimit));
        });
    });
    return edges;
};
louisgreiner commented 3 days ago

@shenriotpro I think it is related to the fact that trainruns can have no EndNode (without root)

shenriotpro commented 3 days ago

I see two issues with this example:

  1. The assumption is that trainruns are one or several (caveat https://github.com/SchweizerischeBundesbahnen/netzgrafik-editor-frontend/issues/285) linked lists, this is not the case here, e.g. with trainrun 85. Iterators make the same assumption, right? image
  2. On the same trainrun 85, the node 135 is not considered an endNode because the two trainrunSections have ports 1149 and 1401, and there is a transition between those ports. https://github.com/SchweizerischeBundesbahnen/netzgrafik-editor-frontend/blob/d67445abbc7ff57767229a46a6a61f0f05ba41ec/src/app/models/node.model.ts#L417
shenriotpro commented 3 days ago

Let's keep in mind that performance may become worse after these issues are fixed.