Method, apparatus, storage medium, and program product for graph retrieval

文档序号:191949 发布日期:2021-11-02 浏览:15次 中文

阅读说明:本技术 用于图检索的方法、设备、存储介质和程序产品 (Method, apparatus, storage medium, and program product for graph retrieval ) 是由 汪洋 袁鹏程 陈曦 李方明 杨仁凯 于 2018-08-27 设计创作,主要内容包括:本公开的实施例提供了用于图检索的方法、设备、存储介质和程序产品。用于图检索的方法包括:基于与目标对象相关联的距离信息,从层级结构中确定与目标对象相关联的父对象,目标对象经由父对象具有到源对象的最小距离,其中距离信息指示目标对象经由与目标对象相关联的每个父对象到源对象的距离;以及基于父对象,确定从源对象到目标对象的最短路径。(Embodiments of the present disclosure provide methods, apparatuses, storage media, and program products for graph retrieval. The method for graph retrieval includes: determining, from the hierarchy, a parent object associated with the target object based on distance information associated with the target object, the target object having a minimum distance to the source object via the parent object, wherein the distance information indicates a distance of the target object to the source object via each parent object associated with the target object; and determining a shortest path from the source object to the target object based on the parent object.)

1. A method for graph retrieval, comprising:

determining, from a hierarchy, a parent object associated with a target object having a minimum distance to the source object via the parent object based on distance information associated with the target object, wherein the distance information indicates a distance of the target object to the source object via each parent object associated with the target object; and

based on the parent object, a shortest path is determined from the source object to the target object.

2. The method of claim 1, further comprising determining distance information associated with objects in the hierarchy based on:

determining a set of objects to be processed from a plurality of sets of objects in the hierarchical structure, wherein the objects of each set of objects in the plurality of sets of objects are respectively in the same hierarchy;

and recording the distance from each object in the plurality of sets of objects to be processed to the source object.

3. The method of claim 2, wherein recording the distance of each object in the plurality of sets of objects to be processed to the source object comprises:

iteratively performing at least one of:

determining whether the number of objects in the set of objects to be processed exceeds a predetermined threshold;

in response to the number exceeding the predetermined threshold, dividing the set of objects to be processed into a plurality of subsets;

processing the plurality of subsets with a plurality of threads, respectively, the processing including at least:

for a first object in the respective subset,

determining a child object associated with the first object, the child object being at a level next to the level at which the first object is located, an

Recording a distance from the child object to the source object via the first object, wherein the first object is marked to avoid duplicate processing;

determining a set of objects corresponding to a level of the sub-objects from the plurality of sets of objects in the hierarchical structure as the set of objects to be processed.

4. The method of claim 3, wherein recording distances from the child objects to the source object via the first object comprises:

determining a first shortest distance from the first object to the source object based on the recorded distances at the first object;

acquiring a second distance from the sub-object to the first object; and

recording the sum of the first shortest distance and the second distance.

5. The method of claim 3, wherein utilizing a plurality of threads to process the plurality of subsets, respectively, comprises:

recording the distances at a plurality of buffers associated with the plurality of threads; and

in response to completion of the plurality of thread executions, merging the distances recorded in the plurality of cache regions into a pre-allocated storage region.

6. The method of claim 5, further comprising:

freeing the plurality of buffers associated with the plurality of threads.

7. The method of claim 2, wherein determining a set of objects corresponding to a hierarchy in which the child object is located comprises:

obtaining at least one child object associated with an object in the plurality of subsets; and

and merging the at least one sub-object to serve as an object set corresponding to the hierarchy of the sub-objects.

8. An electronic device, the electronic device comprising:

one or more processors; and

memory storing one or more programs that, when executed by the one or more processors, cause the electronic device to implement the method of any of claims 1-7.

9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.

10. A computer program product comprising instructions which, when executed by a processor, implement the method according to any one of claims 1-7.

Technical Field

Embodiments of the present disclosure relate generally to the field of data processing, and more particularly, to a method and apparatus, a device, and a computer-readable storage medium for determining a shortest path.

Background

The shortest path problem refers to the problem of how to determine the minimum distance from a source object to a target object, if both have already been determined. The shortest path may be widely applied to various fields, for example, determining a shortest path between a start point to an end point in map navigation, determining a social relationship between two users in a social field, determining a shortest route of two network devices in a network communication field, and the like.

With the development of the information age, the set of objects needing to be processed becomes more and more huge, and the relationship between the objects becomes more and more complex. Therefore, it is more and more time-consuming to determine the shortest path between two objects, and how to improve the calculation efficiency of determining the shortest path has become a focus.

Disclosure of Invention

According to an embodiment of the present disclosure, a scheme is provided for determining a shortest path from a source object to a target object in a hierarchy.

In a first aspect of the disclosure, a method of determining a shortest path from a source object to a target object in a hierarchy is provided. The method comprises the following steps: determining a set of objects to be processed from a plurality of sets of objects in the hierarchical structure, wherein the objects of each set of objects in the plurality of sets of objects are respectively in the same hierarchy; iteratively performing at least one of: determining whether the number of the objects in the set of objects to be processed exceeds a predetermined threshold; in response to the number exceeding the predetermined threshold, dividing the set of objects to be processed into a plurality of subsets; utilizing a plurality of threads to process the plurality of subsets, respectively, the processing at least comprising: for a first object in a respective subset, determining a child object associated with the first object, the child object being at a level next to the level at which the first object is located, and recording a distance from the child object to the source object via the first object; determining an object set corresponding to the level of the child object from the plurality of object sets of the hierarchical structure as the set of the objects to be processed; and determining a shortest path from the source object to the target object based on the recorded distances.

In a second aspect of the disclosure, an apparatus for determining a shortest path from a source object to a target object in a hierarchy is provided. The device includes: the object to be processed determining module is configured to determine a set of objects to be processed from a plurality of sets of objects in a hierarchical structure, wherein the objects of each set of objects in the plurality of sets of objects are respectively in the same hierarchy; an iterative execution module configured to iteratively execute at least one of: determining whether the number of objects in the set of objects to be processed exceeds a predetermined threshold; responsive to the number exceeding a predetermined threshold, dividing the set of objects to be processed into a plurality of subsets; utilizing a plurality of threads to process the plurality of subsets, respectively, the processing at least comprising: for a first object in the respective subset, determining a child object associated with the first object, the child object being at a level next to the level at which the first object is located, and recording a distance from the child object to the source object via the first object; determining an object set corresponding to the level of the child object from a plurality of object sets of the hierarchical structure to serve as a set of objects to be processed; and a shortest path determination module configured to determine a shortest path from the source object to the target object based on the recorded distance.

In a third aspect of the disclosure, an electronic device is provided. The electronic device includes: one or more processors; and memory for storing one or more programs that, when executed by the one or more processors, cause an electronic device to implement a method in accordance with the first aspect of the disclosure.

In a fourth aspect of the present disclosure, a computer-readable medium is provided, on which a computer program is stored which, when executed by a processor, implements a method according to the first aspect of the present disclosure.

It should be understood that the statements herein reciting aspects are not intended to limit the critical or essential features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.

Drawings

The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. In the drawings, like or similar reference characters designate like or similar elements, and wherein:

FIGS. 1A-1B are diagrams illustrating a conventional determination of shortest paths in a hierarchy;

FIG. 2 illustrates a schematic diagram of an exemplary environment in which embodiments of the present disclosure can be implemented;

fig. 3 shows a flow diagram of a method for determining shortest paths in a hierarchy, according to an embodiment of the present disclosure;

FIG. 4 shows a schematic diagram of an example hierarchy structure, according to an embodiment of the present disclosure;

fig. 5 shows a block diagram of an apparatus for determining shortest paths in a hierarchy according to an embodiment of the present disclosure; and

FIG. 6 illustrates a block diagram of an electronic device capable of implementing embodiments of the present disclosure.

Detailed Description

Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.

As mentioned above, computing the shortest path from a source object to a target object is widely used in a variety of fields. Traditionally, depth-first traversal or breadth-first traversal is typically employed to determine the shortest path between two objects. The depth-first traversal is defined as follows: firstly, visiting a starting point v and marking the starting point v as visited; then, starting from v, each adjacent point w of v is searched. If w has not been visited, then the depth-first traversal continues with w as the new starting point until all vertices in the graph that are in path with the source point v (also referred to as vertices reachable from the source point) have been visited.

Fig. 1A shows a conventional diagram 100 for determining the shortest path based on depth-first traversal. As shown in FIG. 1A, including a plurality of objects V1-V9110-190 in FIG. 1A, when depth-first traversal is employed to determine the shortest path from object V1110 to object V9190, the process that it undergoes is as follows:

V1

V1 V2

V1 V2 V5

V1 V2 V5 V6

V1 V2 V5 V6 V7

V1V 2V 5V 6V 7V 9 (find target V9190, record length 5)

V1 V2 V5 V6 V8

V1V 2V 5V 6V 8V 9 (find target V9190, record length 5)

V1 V3

V1 V4

V1 V4 V6

V1 V4 V6 V7

V1V 5V 6V 7V 9 (find target V9190, record length 4)

V1 V4 V6 V8

V1V 4V 6V 8V 9 (find target V9190, record length 4)

As can be seen from the above process, in the process of determining the shortest path from object V1110 to object V9190, objects V6160, V7170, V8180, and V9190 (shown by dashed boxes) are traversed repeatedly a plurality of times. When the number of the objects is large or the connectivity between the objects is high, the depth-first traversal-based method will cause a large number of repeated traversals, thereby greatly affecting the calculation performance. Furthermore, since the shortest path determining algorithm based on depth-first traversal does not have parallelism per se, it cannot take advantage of the multi-threading of existing computing devices.

Another conventional way to determine the shortest path is based on breadth-first traversal. Breadth-first traversal is defined as follows: step 1, starting from a certain object V0 in the graph and accessing the vertex; step 2, starting from V0, accessing each unaccessed adjacent point W1, W2 and … … Wk of V0; then, accessing the non-accessed adjacent points from W1, W2 and … … Wk in sequence; and 3, repeating the step 2 until all the vertexes are visited.

Fig. 1B shows a conventional schematic diagram 100' for determining the shortest path based on breadth-first traversal. As shown in FIG. 1B, FIG. 1B includes a plurality of objects S1-S7110 '-170'. The breadth-first traversal-based sequence is: s1110 ', S2120 ', S3130 ', S4140 ', S5150 ', S6160 ' to S7170 '. For example, when determining the shortest path from the objects S1110 'to S7170', the breadth-first traversal cannot record the path between two objects, and the conventional method needs to generate a traversal tree according to the result of the breadth-first traversal and perform a depth-first traversal on the traversal tree, thereby causing the defect based on the depth-first traversal as described in fig. 1A.

At least in view of the above, embodiments of the present disclosure provide a solution for determining a shortest path from a source object to a destination object in a hierarchy. The scheme is based on breadth-first based traversal, with multiple threads to process multiple objects in each layer in parallel, and records the distance to the source object via the parent object at the child object. The shortest path from the source object to the target object is determined based on the recorded distance to the source object at the target object.

Based on the scheme, the embodiment of the disclosure adopts multiple threads to process multiple objects in parallel, thereby greatly improving the efficiency of determining the shortest path; furthermore, since the distance to the source object is recorded at each object, embodiments of the present disclosure may sequentially determine the objects included in the shortest path based on the recorded distances, without having to determine the shortest path with one additional depth-first traversal, thereby improving the performance of the computation.

Embodiments of the present disclosure will be described in detail below with reference to fig. 2 to 6. FIG. 2 illustrates a schematic diagram of an exemplary environment 200 in which embodiments of the present disclosure can be implemented.

A hierarchy 210 is included in environment 200. In the context of the present disclosure, the term "hierarchy" is a collection of objects organized in a hierarchy, e.g., directed, undirected, weighted, unweighted, connected, disconnected, etc. It should be understood that the above examples are for illustrative purposes only and are not intended to limit the scope of the embodiments of the present disclosure.

As shown in fig. 2, examples of hierarchy 210 may include a map hierarchy 212, a social relationship hierarchy 214, and a network topology hierarchy 216, among others. For example, the map hierarchy 212 may store connectivity between multiple place objects and distances between objects; the friends relationship hierarchy 214 may store the connectivity of social relationships among multiple user objects and the closeness of the social relationships; the network topology hierarchy 216 may store connectivity between multiple network node objects and distances between the objects. It should be understood that the above examples of hierarchical structures are for illustrative purposes only and are not intended to limit the scope of embodiments of the present disclosure.

The computing device 230 may read the hierarchy 210 stored in the storage device 220 to calculate the shortest path 240 from a particular source object to a target object. For example, in some embodiments, the computing device 230 may calculate the shortest traffic path 240 from the starting point to the ending point according to the map hierarchy 212. In some embodiments, the computing device 230 may calculate the shortest social relationship path 240 between two users according to the social relationship hierarchy 214. In some embodiments, the computing device 230 may calculate the shortest network path 240 between two network nodes according to the network topology hierarchy 215.

It should be understood that the number, configuration, connection and arrangement of the various components shown in fig. 2 are exemplary, not limiting, and some of the components may be optional. And one skilled in the art may make adjustments in number, structure, connection relationships, and layout within the scope of the present disclosure.

Fig. 3 shows a flow diagram of a method 300 for determining a shortest path according to an embodiment of the present disclosure. The method 300 may be performed by the computing device 230 shown in fig. 2. Fig. 4 illustrates an example hierarchy 210 in accordance with an embodiment of the present disclosure. The embodiment shown in FIG. 3 will be described in detail below in conjunction with the example hierarchy 210 of FIG. 4. As described above, the example hierarchy 210 in FIG. 4 may be pre-stored in the storage device 220, and the computing device 230 may determine the shortest path from the source object O1402 to the target object O11422, e.g., via the method 300.

At block 302, the computing device 230 determines a set of objects to be processed from a plurality of sets of objects in the hierarchy 210, wherein objects of each set of objects in the plurality of sets of objects are at a same hierarchical level, respectively. As shown in fig. 4, the hierarchy 210 includes a plurality of objects O1402, O2404, … …, O13426. For example, in the hierarchy 210, the object O1402 is located at a first level, and the O2404, O3406, O4408, and O5410 are located at a second level. In the example of fig. 4, the set of objects to be processed determined by computing device 230 from hierarchy 210 is { O1402 }.

At block 304, the computing device 230 determines whether the number of objects in the set of objects to be processed exceeds a predetermined threshold. In some embodiments, the computing device 230 may pre-determine the threshold by balancing the overhead incurred by initiating multithreading with the granularity of parallelism such that the efficiency of processing may be increased by initiating multithreading when the number of objects in the set to be processed exceeds a predetermined threshold. For example, in the example of fig. 4, the predetermined threshold may be set to 3, when the number of objects 1 in the to-be-processed set is less than the predetermined threshold 3.

If it is determined at block 304 that the number of objects does not exceed the threshold, the method 300 proceeds to block 316, where the set of pending objects is processed using the single thread. Specifically, during this process, the computing device 230 first determines a child object associated with an object in the set of objects to be processed, the child object being at a level next to the level at which the object in the set of objects to be processed is located. Taking fig. 4 as an example, for the set { O1402 } of objects to be processed, its child objects include: object O2404, object O3406, object O3408, and object O5410.

Subsequently, the computing device 230 records the sub-objects from the set of objects to be processedDistance of object to source object. Taking fig. 4 as an example, the computing device 230 records the distances to the source object O1402 at the sub-object O2404, the sub-object O3406, the sub-object O3408, and the sub-object O5410, respectively. For example, { O1, Dis can be recorded at object O2404O1-O2In which DisO1-O2Representing the distance of object O2404 from source object O1402.

At block 310, the computing device 230 determines, from the plurality of object combinations of the hierarchy 210, a set of objects corresponding to the hierarchy in which the child object is located as a set of objects to be processed. In some embodiments, computing device 230 may obtain, by the computing device, at least one child object associated with an object in the plurality of subsets. Subsequently, the computing device 230 may merge at least one sub-object as a set of objects corresponding to the hierarchy in which the sub-object is located. Taking fig. 4 as an example, for the set { O1402 } of objects to be processed, its child objects include: an object O2404, an object O3406, an object O3408 and an object O5410, and the new set of objects to be processed is { O2404, O3406, O3408, O5410 }

At block 312, the computing device 230 determines whether the set of objects to be processed is empty. Continuing with the example of FIG. 4, the new set of objects to be processed is { O2404, O3406, O3408, O5410 }. The method 300 returns to block 304 to confirm whether the number of objects in the new set of objects to be processed exceeds a predetermined threshold. Continuing with the example of FIG. 4, the number of objects in the new set of objects to be processed is 4, which is greater than the predetermined threshold 3.

In response to determining at block 304 that the number is greater than the predetermined threshold, the method 300 proceeds to block 306 where the computing device 230 divides the set of objects to be processed into a plurality of subsets. In some embodiments, the computing device 230 may determine the number of divided subsets according to a preset rule. For example, when the number of objects is greater than 3 and less than 100, the object set is divided into 2 subsets on average; when the number of objects reaches 100 and is less than 1000, the set of objects is divided into 4 subsets on average. It should be understood that the above specific numerical values are only examples, and those skilled in the art can flexibly set different division rules according to different hierarchies and different computing devices.

In the example of fig. 4, computing device 230 may divide the set of objects to be processed { O2404, O3406, O4408, O5410 } into 2 subsets { O2404, O3406 } and { O4408, O5410 } in order.

At block 308, the computing device 230 processes the plurality of subsets with a plurality of threads, respectively. In some embodiments, computing device 230 may pre-set a thread pool and select multiple threads from the thread pool to process multiple subsets as needed. In some embodiments, computing device 230 may also create new threads for processing multiple sub-collections. In the example of FIG. 4, the subset { O2404, O3406 } and the subset { O4408, O5410 } may be processed separately with 2 threads.

As shown in FIG. 3, block 308 includes determining a child object for each object in the respective subset, and recording the distance of the child object from the source object via the object. In particular, at block 308A, the computing device 230 determines a child object associated with the first object, the child object being at a level next to the level at which the first object is located. Continuing with the example of fig. 4, for the first object O2404 in the subset { O2404, O3406 }, the computing device 230 may determine that its child object is O6412.

At block 308B, the computing device 230 records the distance from the child object to the source object via the first object. In some embodiments, the computing device 230 may determine a first shortest distance from the first object to the source object based on the recorded distance at the first object. For example, for the first object O2404, the shortest recorded distance to the source object O1402 is DisO1-O2. The computing device 230 may then obtain a second distance of the sub-object from the first object. For example, for the child object O6412, its distance to the first object O2404 may be represented as DisO1-O2. The computing device 230 may record a sum of the first shortest distance and the second distance. For example, for sub-object O6412, the computing device 230 may record { O2, Dis at object O6412O1-O2+DisO1-O2Represents the distance to the source object O1402 via the first object O2404.

In some embodiments, after recording all the distances of the children objects of the first object from the source object via the first object, the computing device 230 may mark the first object to avoid the first object being processed repeatedly.

In some embodiments, computing device 230 may allocate a corresponding cache region for each thread that is started and record the distance of the child object from the source object via the first object at the cache region associated with each thread.

In some embodiments, computing device 230 may merge distances recorded in cache regions associated with threads into pre-allocated storage regions after multiple threads complete processing of the respective subsets. In this way, write conflicts for the same memory space for multiple threads that may exist, for example, for object O11422, if object O6412 and object O7414 are assigned to process with different threads, write conflicts may occur for both threads recording the distance of object O11422 to source object O1402 via object O6412 and via object O7414, respectively. In some embodiments, after the merge is completed, computing device 230 may release the cache associated with the thread.

Subsequently, the method 300 proceeds to block 310, where the computing device 230 determines a set of objects from the plurality of combinations of objects in the hierarchy 210 that corresponds to the level at which the child object is located as the set of objects to be processed. As described above, the computing device 230 may obtain, by the computing device, at least one child object associated with an object in the plurality of subsets. Subsequently, the computing device 230 may merge at least one sub-object as a set of objects corresponding to the hierarchy in which the sub-object is located. Continuing with the example of FIG. 4, for the set of objects to be processed { O2404, O3406, O4408, O5410 }, its child objects include: object O6412, object O4408, object O7414, object O8416, object O9418, and object O10420. In some embodiments, the determined new set of objects to be processed is { O6412, O7414, O8416, O9418, O10420 } because object O4408 has been marked as no longer being processed repeatedly during the previous processing.

In the following process, step 304 and 302, or steps 304, 316, 310 and 312, may be iteratively performed for the new pending set. When the new pending set determined at 312 is empty, computing device 230 may determine that all objects in hierarchy 210 have been processed, at which point method 300 ends the iteration. In this case, for the hierarchical structure 210 shown in fig. 4, the distance information recorded in each object is as follows:

O2 404:{O1,DisO1-O2};

O3 406:{O1,DisO1-O3};

O4 408:{O1,DisO1-O4},{O3,DisO1-O3+DisO3-O4};

O5 410:{O1,DisO1-O5};

O6 412:{O2,DisO1-O2+DisO2-O6},{O3,DisO1-O3+DisO3-O6};

O7 414:{O3,DisO1-O3+DisO3-O7};

O8 414:{O4,DisO1-O4+DisO4-O8},{O11,min(DisO1-O8)+DisO11-O8};

O9 414:{O5,DisO1-O5+DisO5-O9};

O10 420:{O5,DisO1-O5+DisO5-O10};

O11 422:{O6,min(DisO1-O6)+DisO6-O11},{O3,min(DisO1-O3)+DisO3-O11},{O7,min(DisO1-O7)+DisO7-O11};

O12 424:{O9,DisO1-O9+DisO9-O12},{O11,min(DisO1-O11)+DisO11-O12};

O13 426:{O11,min(DisO1-O11)+DisO11-O13}。

taking the information recorded by O11422 as an example, it records the distances from three different parent objects O6412, O3406 and O7414 to the source object O1402, where min (Dis)O1-O6) Representing the shortest distance recorded at object O6412 to source object O1402.

At block 314, the computing device 230 determines the shortest path from the source object to the target object based on the recorded distances. In particular, computing device 230 may determine, from the plurality of sets of objects, a parent object associated with a target object having a minimum distance to the target object via the parent object based on a distance recorded at the target object.

Continuing with the example of FIG. 4, for target object O11422, which has three parent objects, O6412, O3406, and O7414, respectively. The computing device 230 may select the target object corresponding to the shortest distance as the path object on the shortest path. For example, for the sake of simplicity, when the hierarchy of fig. 4 is an unweighted graph, the distance between every two adjacent objects is 1. At this time, the distance information recorded at the object O11422 is: { O6, 3}, { O3, 2}, { O7, 3 }. Thus, it may be determined that the shortest path from source object O1402 to target object O11422 includes parent object O3406.

Subsequently, computing device 230 may determine a shortest path from the source object to the target object based on the determined parent object. Continuing with the example of fig. 4, for determined parent object O3406, computing device 230 may determine the shortest path using the distance recorded at parent object O3406. Since only O1, Dis is recorded at the object O3406O1-O3Therefore, the next object in the shortest path is O1402, i.e. the source object, at this time, the shortest path from source object 402 to target object 422 has been found: o1402, O3406, O11422. It should be appreciated that the step of finding a parent object may be performed iteratively until a source object is found, thereby determining the shortest path from the source object to the target object.

According to the embodiment of the disclosure, the breadth-first-based traversal of various types of hierarchies (such as a map hierarchy, a social relationship hierarchy, a network connection hierarchy and the like) in various fields can be utilized, and the characteristics that the breadth-first is parallelizable are utilized, so that the efficiency of determining the shortest path is greatly improved, the use experience of a user can be improved, for example, a navigation path from a starting point to an end point is determined more quickly, a social connection with a certain user is found more quickly, a shortest routing path with a certain network device is determined more quickly, and the like. Furthermore, since the distance to the source object is recorded at each object, embodiments of the present disclosure may efficiently determine the object included in the shortest path based on the recorded distance without having to utilize additional depth-first traversal, thereby improving the performance of the computation.

Fig. 5 shows a block diagram of an apparatus 500 for determining a shortest path according to an embodiment of the present disclosure. The apparatus 500 may be included in the computing device 230 of fig. 2 or implemented as the computing device 230. As shown in fig. 5, the apparatus 500 includes a to-be-processed object determining module 510 configured to determine a set of to-be-processed objects from a plurality of sets of objects in a hierarchical structure, where objects of each set of objects in the plurality of sets of objects are respectively at the same hierarchical level. The apparatus 500 further comprises an iterative execution module 520 configured to iteratively perform at least one of: determining whether the number of objects in the set of objects to be processed exceeds a predetermined threshold; responsive to the number exceeding a predetermined threshold, dividing the set of objects to be processed into a plurality of subsets; utilizing a plurality of threads to process the plurality of subsets, respectively, the processing at least comprising: for a first object in the respective subset, determining a child object associated with the first object, the child object being at a level next to the level at which the first object is located, and recording a distance from the child object to the source object via the first object; and determining an object set corresponding to the hierarchy where the child objects are located from a plurality of object sets of the hierarchical structure to serve as the object set to be processed. The apparatus 500 further includes a shortest path determination module 530 configured to determine a shortest path from the source object to the target object based on the recorded distances.

In some embodiments, the iterative execution module 520 may include: a marking module configured to mark the first object to avoid the first object being repeatedly processed.

In some embodiments, the iterative execution module 520 may include: a shortest distance determination module configured to determine a first shortest distance from the first object to the source object based on the recorded distance at the first object; a second distance acquisition module configured to acquire a second distance from the sub-object to the first object; and a sum recording module configured to record a sum of the first shortest distance and the second distance.

In some embodiments, the iterative execution module 520 may include: a distance recording module configured to record distances at a plurality of buffers associated with a plurality of threads; and a merging module configured to merge distances recorded in the plurality of cache areas into the pre-allocated storage area in response to completion of the plurality of threads.

In some embodiments, the iterative execution module 520 may include: a release module configured to release a plurality of buffers associated with a plurality of threads.

In some embodiments, the iterative execution module 520 may include: a sub-object acquisition module configured to acquire at least one sub-object associated with an object in a plurality of subsets; and the sub-object merging module is configured to merge at least one sub-object to serve as an object set corresponding to the hierarchy where the sub-object is located.

In some embodiments, the shortest path determining module 530 may include: a parent object determination module configured to determine a parent object associated with the target object from the plurality of object sets based on the recorded distance at the target object, the target object having a minimum distance to the target object via the parent object; and a shortest path generating module configured to generate a shortest path based on the parent object.

FIG. 6 illustrates a schematic block diagram of an electronic device 600 that may be used to implement embodiments of the present disclosure. Device 600 may be used to implement computing device 230 of fig. 1. As shown, device 600 includes a Central Processing Unit (CPU)601 that may perform various appropriate actions and processes in accordance with computer program instructions stored in a Read Only Memory (ROM)602 or loaded from a storage unit 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the device 600 can also be stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.

A number of components in the device 600 are connected to the I/O interface 605, including: an input unit 606 such as a keyboard, a mouse, or the like; an output unit 607 such as various types of displays, speakers, and the like; a storage unit 608, such as a magnetic disk, optical disk, or the like; and a communication unit 609 such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.

The processing unit 601 performs the various methods and processes described above, such as the method 300. For example, in some embodiments, the method 300 may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 600 via the ROM 602 and/or the communication unit 609. When the computer program is loaded into RAM 603 and executed by CPU 601, one or more steps of method 300 described above may be performed. Alternatively, in other embodiments, CPU 601 may be configured to perform method 300 by any other suitable means (e.g., by way of firmware).

The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a load programmable logic device (CPLD), and the like.

Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

Further, while operations are depicted in a particular order, this should be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single implementation. Conversely, various features that are described in the context of a single implementation can also be implemented in multiple implementations separately or in any suitable subcombination.

Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种被阻挡分段的预测方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!