@@ -41,20 +41,22 @@ def seriate(
4141 dists : numpy .ndarray , approximation_multiplier : int = 1000 , timeout : float = 2.0
4242) -> list [int ]:
4343 """
44- Order the elements of a set so that the sum of sequential pairwise distances is minimal.
44+ Order the elements of a set so that the sum of sequential pairwise
45+ distances is minimal.
4546
4647 We solve the Travelling Salesman Problem (TSP) under the hood.
4748 Reference: http://nicolas.kruchten.com/content/2018/02/seriation/
4849
49- :param dists: Either a condensed pdist-like or a symmetric square distance matrix.
50- :param approximation_multiplier: Multiply by this number before converting distances \
51- to integers.
52- :param timeout: Maximum amount of time allowed to spend for solving the TSP, in seconds. \
53- This value cannot be less than 0. If timeout is 0 it will try to solve \
54- the problem with timeout = 1, and double the timeout every time it fails \
55- until a valid solution is found.
56- :return: list with ordered element indexes, the same length as the number of elements \
57- involved in calculating `dists`.
50+ :param dists: Either a condensed pdist-like or a symmetric square distance
51+ matrix.
52+ :param approximation_multiplier: Multiply by this number before converting
53+ distances to integers.
54+ :param timeout: Maximum amount of time allowed to spend for solving the TSP,
55+ in seconds. This value cannot be less than 0. If timeout is 0
56+ it will try to solve the problem with timeout = 1, and double
57+ the timeout every time it fails until a valid solution is found.
58+ :return: list with ordered element indexes, the same length as the number of
59+ elements involved in calculating `dists`.
5860 """
5961 _validate_data (dists )
6062 if timeout > 0 :
@@ -83,17 +85,20 @@ def _seriate(
8385 dists : numpy .ndarray , approximation_multiplier = 1000 , timeout = 2.0
8486) -> list [int ]:
8587 """
86- Order the elements of a set so that the sum of sequential pairwise distances is minimal.
88+ Order the elements of a set so that the sum of sequential pairwise
89+ distances is minimal.
8790
8891 We solve the Travelling Salesman Problem (TSP) under the hood.
8992 Reference: http://nicolas.kruchten.com/content/2018/02/seriation/
9093
91- :param dists: Either a condensed pdist-like or a symmetric square distance matrix.
92- :param approximation_multiplier: Multiply by this number before converting distances \
93- to integers.
94- :param timeout: Maximum amount of time allowed to spend for solving the TSP, in seconds.
95- :return: list with ordered element indexes, the same length as the number of elements \
96- involved in calculating `dists`.
94+ :param dists: Either a condensed pdist-like or a symmetric square distance
95+ matrix.
96+ :param approximation_multiplier: Multiply by this number before converting
97+ distances to integers.
98+ :param timeout: Maximum amount of time allowed to spend for solving the TSP,
99+ in seconds.
100+ :return: list with ordered element indexes, the same length as the number of
101+ elements involved in calculating `dists`.
97102 """
98103 assert dists [dists < 0 ].size == 0 , "distances must be non-negative"
99104 assert timeout > 0
0 commit comments