Написать логику для задачи на тему графов на JS

3 000 руб. за проект
03 апреля 2022, 19:29 • 4 отклика • 54 просмотра
Решить задачу по графу

Input: A directed graph where a node represents a town , and an edge represents a route
between two towns. The weighting of the edge represents the delivery cost between the two
towns. Thee towns are named using the first letters of the alphabet. A route between two towns,
from A to town B, with a cost of 1, is represented as AB1.
Example:
AB1, AC4, AD10, BE3, CD4, CF2, DE1, EB3, EA2, FD1

Case 1: Calculate the delivery cost for a given delivery route. Follow the route as given; do not
count any extra stops. In case the given route does not exist, output ’No Such Route’

Case 2: Calculate the number of possible delivery routes that can be constructed by given
conditions. (Do not count a route that has 0 cost)