Algorithm: Connector Optimization

Suppose that there are nvarious points in three-dimensional space, namely P1, P2, P3, ..., Pn.

Define the connector Cas an ordered set of line segments, where the next element in the set should have a common vertex with the previous one. For example, { P1-P2, P2-P4, P4-P7 }this is a connector, but { P1-P2, P3-P4,P4-P2 }not.

Define the contents of the connector as the set of points that the connector includes.

Define the size of the connector as the length of the longest single segment in the connector.

Define the connector as the correct connector if the longest single segment is the first or last segment in the connector.

A set of points is called connected if the union of the contents of the connectors above the points is a set of points.

The problem is this:

Given that the kcorrect connectors ( k < n) with the same size mallow the connection of points nwhose coordinates are given, minimize m.

What should be the essence of the algorithm? I don’t know where to start.

+4
source share
2 answers

The idea is to start from the most distant point, i.e. its nearest neighbor is the farthest compared to other neighboring points. Then create from this connector, always adding the next neighbor of the next point, until you can add more points without breaking one of these rules:

  • A connector cannot have cycles (a point can only be visited once)
  • ,

NB: , , , , "" , : .

, , . . k , , .

, , . , , , , , , .

:

Pre-processing:
    List for each point all the other points in order of increasing distance from it.

    set m = 0

Repeat:
    set max_dist = 0, list = empty
    For each point p:
        Find the first neighbor q for which distance(p,q) > m
        if distance(p,q) >= max_dist:
            if distance(p,q) > max_dist:
                clear list
            append (p,q) to the list

    let m = max_dist
    For each pair (p,q) in the list (all these pairs have same distance m):
        Let result = []
        Let connector be [p,q]
        Let p = q

        Recursive part (p):
            let end_point = True
            For each neighbor q of p (in order of distance):
                If distance(p,q) > m: 
                    break loop
                If q not in connector:
                    let end_point = False
                    Append q to connector
                    Call the recursive part for q
                    size(result) >= k and all points are in result:
                        exit recursion
                    Remove q from connector (backtracking)

            If end_point:
                append clone of connector to result

        If size(result) >= k and all points are in result:
            return m, as final result
0

. , . , , . - , . , .

. , .

. node. node. node node, . , . , , .

. . . node B, Q , AB, BC PQ, QR. AQ, QC PB, BR , .

.

0

Source: https://habr.com/ru/post/1655688/


All Articles