WO2015043208A1 - 一种最短路径查询方法及装置 - Google Patents

一种最短路径查询方法及装置 Download PDF

Info

Publication number
WO2015043208A1
WO2015043208A1 PCT/CN2014/078134 CN2014078134W WO2015043208A1 WO 2015043208 A1 WO2015043208 A1 WO 2015043208A1 CN 2014078134 W CN2014078134 W CN 2014078134W WO 2015043208 A1 WO2015043208 A1 WO 2015043208A1
Authority
WO
WIPO (PCT)
Prior art keywords
level
nodes
node
shortest path
aggregation area
Prior art date
Application number
PCT/CN2014/078134
Other languages
English (en)
French (fr)
Inventor
王靓伟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015043208A1 publication Critical patent/WO2015043208A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/12Shortest path evaluation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/02Topology update or discovery
    • H04L45/04Interdomain routing, e.g. hierarchical routing

Definitions

  • the present invention relates to the field of information technology, and in particular, to a shortest path query method and apparatus. Background technique
  • Determining the shortest path between nodes is the basic operational requirement in database applications.
  • the traditional way to obtain the shortest path is to temporarily calculate the shortest path when querying the database.
  • the graph data in the entire database cannot be read through the memory at one time, so many traditional memory-based graph algorithms need to be re-adjusted, and only a part of the required graph data can be loaded for calculation at a time instead of loading the entire time.
  • the graph data in the database seriously reduces the query efficiency.
  • the pre-processing of the graph data in the database is started.
  • One of the more common methods is to pre-calculate and store the shortest path between all nodes in the database; however, this method will be expensive.
  • the storage space even causes storage devices, such as memory, hard disks, etc. to overflow, affecting normal workflows. Summary of the invention
  • the present invention provides a shortest path query method and apparatus for solving the problem of pre-calculating and storing the shortest path between all nodes in the database, which consumes a large storage space.
  • a shortest path query method including:
  • Determining and storing the aggregation area of each level to which each node in the database belongs, and the shortest path between each node and the central node of the aggregation area of each level, and the aggregation area of the highest level The shortest path between the central nodes; where the high-level aggregation area contains multiple different low-level aggregation areas; for any level of aggregation area, the adjacent aggregation area includes at most one common node or at most one Said a lower level of the aggregation level of any level;
  • determining a first-level aggregation area to which each node in the database belongs respectively includes:
  • determining an N-th aggregation region to which each node in the database belongs, where N is a positive integer greater than 1, including:
  • Each N-1th-level aggregation area is an N-1th-level virtual node, and accesses an un-accessed degree N-1-level virtual node in the database, and the largest degree
  • the virtual node of the N-1th level has all the N-1th virtual nodes of the directly connected side, and the virtual node of the N-1th level with the highest degree of access and the Nth with the largest degree All virtual nodes of the N-1 level of the -1 level virtual node have a directly connected edge to form an Nth level aggregation area;
  • determining, in each of the nodes in the database, respectively, the center of the aggregation region of each level The shortest path between nodes including:
  • the shortest path between each node in the database and the central node of the associated high-level aggregation area is determined according to the determined shortest path between each node and the central node of the associated low-level aggregation area.
  • determining two nodes in the query request according to the stored aggregation area and the shortest path Before the shortest path between it also includes:
  • the shortest path between the two nodes and the central node of the highest-level aggregation area, and the two The shortest path between the central nodes of the highest level aggregation area to which the nodes belong respectively is the shortest path between the two nodes;
  • the two nodes in the query request belong to the same highest-level aggregation area, it is determined whether there is a different M-th aggregation area to which the two nodes belong, where M is a positive integer, and the The M level is the highest level among the different aggregation levels of the same level to which the two nodes belong; if present, the two nodes are respectively associated with the central node of the aggregation area of the M+1th level to which the node belongs.
  • the shortest path is the shortest path between the two nodes. If not, the shortest path between the two nodes and the central node of the first-level aggregation area of the first level is used as the two nodes. The shortest path between.
  • the second aspect provides a shortest path querying device, where the apparatus includes: a first determining module, configured to determine and store an aggregated area of each level to which each node in the database belongs, and each node The shortest path between the central node of the aggregation area of each level and the shortest path between the central nodes of the aggregation area of the highest level; wherein the high-level aggregation area contains a plurality of different low-level Aggregation area; for any level of aggregation area, the adjacent aggregation area includes at most one common node or at most one aggregation area lower than the arbitrary one level;
  • a second determining module configured to determine, according to the stored aggregated area and the shortest path, a shortest path between the two nodes in the query request.
  • the first determining module is specifically used to:
  • the first determining module is specifically configured to determine, according to the following steps, an aggregation of an Nth level to which each node in the database belongs respectively Area, N is a positive integer greater than 1, and:
  • Each N-1th-level aggregation area is an N-1th-level virtual node, and accesses an un-accessed degree N-1-level virtual node in the database, and the largest degree
  • the virtual node of the N-1th level has all the N-1th virtual nodes of the directly connected side, and the virtual node of the N-1th level with the highest degree of access and the Nth with the largest degree All virtual nodes of the N-1 level of the -1 level virtual node have a directly connected edge to form an Nth level aggregation area;
  • the second determining module is specifically configured to:
  • the shortest path between each node in the database and the central node of the associated high-level aggregation area is determined according to the determined shortest path between each node and the central node of the associated low-level aggregation area.
  • the second determining module is further configured to: according to the stored aggregation area and the shortest The path, before determining the shortest path between the two nodes in the query request, determines that there is no directly connected edge between the two nodes in the query request.
  • the second determining module is specifically configured to:
  • the shortest path between the two nodes and the central node of the highest-level aggregation area, and the two The shortest path between the central nodes of the highest level aggregation area to which the nodes belong respectively is the shortest path between the two nodes; If it is determined that the two nodes in the query request belong to the same highest-level aggregation area, it is determined whether there is a different M-th aggregation area to which the two nodes belong, where M is a positive integer, and the The M level is the highest level among the different aggregation levels of the same level to which the two nodes belong; if present, the two nodes are respectively associated with the central node of the aggregation area of the M+1th level to which the node belongs.
  • the shortest path is the shortest path between the two nodes. If not, the shortest path between the two nodes and the central node of the first-level aggregation area of
  • an aggregation area of each level to which each node in the database belongs is determined and stored, and a shortest path between each node and a central node of the aggregation area of each level to which the node belongs, and a different highest level
  • the shortest path between the central nodes of the aggregation area determines the shortest path between the two nodes in the query request according to the stored aggregation area and the shortest path.
  • the pre-stored aggregation area in the present invention occupies less storage space and is stored.
  • the shortest path is only the shortest path between each node and the central node of the associated aggregation area and the shortest path between the central nodes of the highest level aggregation area, so the required storage space is also small;
  • the method according to the stored aggregation area and the shortest path, can determine the shortest path between the two nodes in the query request, and the query efficiency is high.
  • FIG. 1 is a flowchart of a shortest path query method according to Embodiment 1 of the present invention.
  • FIG. 2 is a schematic view showing formation of a first-level polymerization region according to an embodiment of the present invention
  • FIG. 5 is a structural diagram of a shortest path query device according to Embodiment 1 of the present invention
  • FIG. 6 is a structural diagram of a shortest path query device according to Embodiment 2 of the present invention. detailed description
  • each level of each node in the database is determined and stored.
  • the aggregation area, and the shortest path between each node and the central node of each aggregation area of each level, and the shortest path between the central nodes of different highest level aggregation areas, according to the stored aggregation area and the shortest path is determined.
  • the pre-stored aggregation area occupies less storage space, and the stored shortest path is only the central node of each node and the associated aggregation area.
  • the shortest path between the shortest path and the shortest path between the central nodes of the highest level of the aggregation area so the required storage space is also small; using the method of the embodiment of the present invention, according to the stored aggregation area and the shortest path, Determining the shortest path between two nodes in the query request, the query efficiency is higher.
  • a flowchart of a shortest path query method according to Embodiment 1 of the present invention includes the following steps:
  • S101 Determine and store an aggregation area of each level to which each node in the database belongs, and a shortest path between each node and a central node of each aggregation area of each level, and a different highest level of aggregation The shortest path between the central nodes of the area; where the high-level aggregation area contains multiple different low-level aggregation areas; for any level of aggregation area, the adjacent aggregation area includes at most one common node or at most one An aggregation area that is one level lower than any one of the above levels;
  • S102 Determine a shortest path between two nodes in the query request according to the stored aggregation area and the shortest path.
  • the nodes in the database can be divided into one level or multiple levels of aggregation areas, that is, one level or multiple levels of area aggregation are performed on the nodes in the database, where the high-level aggregation area is If the aggregation is performed on the basis of the low-level aggregation area, there is one central node in each aggregation area of each level.
  • the aggregation area of the first level is composed of the central node and the neighbor nodes of the central node, and the aggregation area of the N-th level It is composed of an aggregation area of the N-1th level of the center and a neighboring aggregation area of the N-1th level of the aggregation area of the N-1th level of the center;
  • two of the query requests can be determined.
  • the shortest path between nodes for example, if two nodes in the query request are non-central nodes in the same first-level aggregation area, and there are no directly connected edges between them, then the two can be The shortest path between the node and the central node of the aggregation area of the first level to which it belongs is the shortest path between the two nodes.
  • step S101 determining, according to the first level of the aggregation area that each node in the database belongs to, includes:
  • a node with the largest degree of accession may be selected from the database, and the node with the largest degree and the node directly connected with the node with the highest degree constitute a first-level aggregation area; Perform this step until all the nodes in the database have the first-level aggregation area, and you can get all the first-level aggregation areas.
  • FIG. 2 a schematic diagram of forming an aggregation area of a first level, first, selecting a node 1 having the largest degree of access from the database, and the node 1 and a node having a direct connection with the node 1 2 ⁇ constitutes a first-level aggregation area ⁇ , and continues to select the node 8 having the largest degree from the remaining un-accessed nodes, and the node 8 and the nodes 9 ⁇ 13 having the directly connected side with the node 8 Forming the second first level aggregation area 8', and continuing to select the node 14 having the largest degree from the remaining unvisited nodes, and the node 14 and the node 15 having the directly connected side with the node 14 ⁇ 20 constituting a third first level of the aggregation area 14 ′, thus forming a first level of the aggregation area 1 ′, 8 ′, 14 ′, the three aggregation areas form a first level of the aggregation area network, in the specific implementation process If there are common no
  • the shortest path between each non-central node and the central node is the edge of the direct connection between each non-central node and the central node. Therefore, the first-level aggregation area network is stored, that is, Storing the central node and non-central node included in each first-level aggregation area After that, it is equivalent to storing the shortest path from each non-central node to the central node;
  • the path length corresponding to the shortest path is the shortest distance, that is, if the distance between the directly connected edges of the nodes is 1, the shortest between the non-central nodes and the central node in FIG. The distance is 1; in the embodiment of the present invention, if only the nodes in the database are divided into one level of the aggregation area, that is, the first level of the aggregation area, when determining the shortest path between the two nodes according to the query request, If there is a directly connected edge between two nodes, the directly connected edge can be used as the shortest path between them.
  • the shortest path between node 2 and node 15 is 5 ⁇ 15; if the two nodes are non-central nodes of the same first-level aggregation area, and there is no directly connected edge between them, the shortest path between them is respectively associated with them.
  • the shortest path between the central nodes of the first level of aggregation area as shown in Figure 2, the shortest path between node 2 and node 3 is 2 ⁇ 1 ⁇ 3; For nodes in different first-level aggregation areas, and there are no directly connected edges between them, the shortest path between them is the shortest between them and the central node of the first-level aggregation area.
  • the path, and the shortest path between the central nodes of the first-level aggregation area to which they belong respectively, as shown in FIG. 2, the shortest path between node 2 and node 10 is 2 1 4 8 10 .
  • nodes in the database are divided into multiple levels of aggregation areas, you can continue to aggregate the aggregation areas of the first level in the following manner.
  • the aggregation area of the third level to which each node in the database belongs is determined, and ⁇ is a positive integer greater than 1, including:
  • Each N-1th-level aggregation area is an N-1th-level virtual node, and accesses an un-accessed degree N-1-level virtual node in the database, and the largest degree
  • the virtual node of the N-1th level has all the N-1th virtual nodes of the directly connected side, and the virtual node of the N-1th level with the highest degree of access and the Nth with the largest degree -1 level virtual node has all N-1th virtual nodes of the directly connected side to form a second level of aggregation area;
  • Hierarchical virtual node storage storing each level of the aggregation area in the hierarchical virtual node memory, and the shortest path between each node in each aggregation area and the central node of the aggregation area; Actually, it is necessary to directly set the above N value, or stop the area aggregation when the number of regions corresponding to the database is less than the set threshold.
  • a schematic diagram is formed for the second-level aggregation area, where the first-level aggregation areas 1', 8', and 14' are respectively three virtual nodes, and one of the databases is selected to be the most unaccessed.
  • the virtual node ⁇ , the virtual node 8' and 14' of the virtual node ⁇ and the virtual node ⁇ directly connected to the virtual node ⁇ constitute a second level of the aggregation area ⁇ ; from the figure, the second level of the aggregation area
  • the central node of the first level is the central node 1 of the first level of the aggregation area ;;
  • the shortest path between each node and the central node of the aggregation area of the second level to which it belongs if there is a common node between the central aggregation area of the first level and its neighbor aggregation area, such as ⁇ and 8' If there is a common node 4, the shortest path between the central node of the first-level neighbor aggregation area and the central node of the associated second-level aggregation area is the central node of the first-level neighbor aggregation area and the The shortest path between the common nodes, and the shortest path between the common node and the central node of the second level of the aggregated area, such as the shortest path between the central node 8 of 8' and the central node 1 of ⁇ is 8 4 1 , the distance between each side is recorded as 1, and the shortest distance is 2, and at the same time, except for the public node, the non-central node of the first-level neighbor aggregation area and the center of the second-level aggregation
  • the shortest path between the nodes is the shortest path between the central node of the first-level neighbor aggregation area and the central node of the second-level aggregation area.
  • the shortest path between the non-central node of the first-level neighbor aggregation area and the central node of the first-level neighbor aggregation area that is, the non-central node of the first-level neighbor aggregation area and the first
  • a shortest path between the public node and the central node of the second-level aggregation area is between the non-central node of the first-level neighbor aggregation area and the central node of the second-level aggregation area of the first level
  • the shortest path, such as the shortest path between the non-central node 11 of 8' and the central node 1 of ⁇
  • the central node of the first level of the neighbor aggregation area and the associated node is the central node of the first-level neighbor aggregation area and the edge of the first-level neighbor aggregation area that is directly connected to the first-level central aggregation area.
  • the shortest path between the central node 14 of 14' and the central node 1 of the crucible is 14 15 5 1 , and the distance of each side is recorded as 1, and the shortest distance is 3, and the side corresponding to the directly connected side corresponds to Outside the node
  • the shortest path between the non-central node of the first-level neighbor aggregation area and the central node of the second-level aggregation area belongs to the above-mentioned
  • the shortest path between the central node of the first-level neighbor aggregation area and the central node of the second-level aggregation area belongs to the non-central node of the first-level neighbor aggregation area and the neighbor aggregation area of the first level
  • the shortest path between the central nodes such as the
  • determining a shortest path between each node in the database and a central node of the aggregation area of each level belongs to, including:
  • the shortest path between each node in the database and the central node of the associated high-level aggregation area is determined according to the determined shortest path between each node and the central node of the associated low-level aggregation area.
  • each node after determining the shortest path between each node and the central node of the associated low-level aggregation area, each node may be determined according to the central node of the associated lower-level aggregation area.
  • the shortest path between each node determines the high level of each node
  • each node in the database is determined to belong to each node according to the shortest path between each node determined to be lower than the central node of the aggregation region of the Nth level of the associated aggregation level.
  • the shortest path between the central nodes of the Nth level aggregation area may be, but is not limited to, the following:
  • any one of the nodes and the central node of the aggregation area of the Nth level belong to the same N-1 level aggregation area, the any one of the nodes
  • the shortest path between the central node of the aggregation region of the Nth-level aggregation region to which it belongs is the shortest path between the arbitrary node and the central node of the aggregation region of the Nth-level aggregation region; wherein N is greater than 1.
  • N>2 common aggregation level of the N-2th level
  • any one of the nodes and the central node of the aggregation area of the Nth level do not belong to the same N-1 level aggregation area, and the any one of the nodes is not the center of the belonging N-1 level aggregation area.
  • the node which is not the edge of the direct connection between the aggregation area of the N-1th level and the aggregation area of the N-1th level to which the central node of the aggregation area of the Nth level belongs And determining, by the node in the aggregation node of the N-th level, the node of the aggregation level of the N-1 level and the node of the aggregation area of the N-th level Whether there is a common node or a common N-2th aggregation area between the aggregation areas of the N-1 level, and if so, the any node and the central node of the aggregation area of the N-1th level belong to Shortest path between, the shortest path between the central node of
  • any one of the nodes is a node corresponding to the directly connected edge between the aggregation area of the N-1th level and the aggregation area of the N-1th level to which the central node of the aggregation area of the Nth level belongs
  • the shortest path between the directly connected edge and another node corresponding to the directly connected edge and the central node of the Nth-level aggregation region is used as the arbitrary node and the associated node
  • the node in the aggregation level of the N-2th level to which the any node belongs belongs to the node corresponding to the directly connected edge.
  • the shortest path between the central nodes of the aggregation area of the (Nth-2)th level, the shortest path between the central node of the aggregation area of the N- 2th level and the central node of the aggregation area of the Nth level, as the shortest path The central section of any node and its associated N-th aggregation area The shortest path between the points; if N>3, it is necessary to continue to determine whether the any one of the nodes belongs to the node in the aggregation area of the N-3th level to which the node corresponding to the direct connection is located, and according to the judgment result , determining that any one of the nodes and the central node of the aggregation area of the Nth level belong to are not described again.
  • the method further includes:
  • the directly connected edge may be regarded as the shortest path between the two nodes, if there is no direct relationship between the two nodes.
  • the edge of the connection determines the shortest path between the two nodes in the query request based on the shortest path stored.
  • step S102 determining, according to the stored aggregation area and the shortest path, the shortest path between the two nodes in the query request, including:
  • the shortest path between the two nodes and the central node of the highest-level aggregation area, and the two The shortest path between the central nodes of the highest level aggregation area to which the nodes belong respectively is the shortest path between the two nodes;
  • the shortest distance corresponding to the shortest path between the two nodes in the query request is expressed by a formula:
  • Douter d(s, c + ⁇ , ⁇ ) + d(c 2 , t);
  • d is the shortest distance between the two nodes in the query request
  • d(s, Cl ) is the shortest distance between the node s and the central node C1 of the highest level aggregation region
  • d( Cl , c 2 ) is the shortest distance between the central node of the highest level aggregation area to which the node s and the node t belong
  • (: 2 , d(c 2 , t) is the highest level aggregation area to which the node t and the node t belong The shortest distance between the central nodes c 2 .
  • the two nodes in the query request belong to the same highest-level aggregation area, it is determined whether there is a different M-level aggregation area to which the two nodes belong, where M is a positive integer, where the aggregation area of the Mth level is the highest level among different aggregation levels of the same level to which the two nodes belong; if yes, the two nodes are respectively the same M+
  • the shortest path between the central nodes of the aggregation area of the level 1 is the shortest path between the two nodes. If not, the two nodes are respectively associated with the same first level of the aggregation area of the first level.
  • the shortest path between the nodes acts as the shortest path between the two nodes.
  • the shortest distance corresponding to the shortest path between the two nodes in the query request is expressed by a formula:
  • d inner is the shortest distance between two nodes in the query request
  • d(s, c) is the shortest distance between the node s and the central node c of the highest-level aggregation region to which it belongs
  • d (c, t) is the shortest distance between the node t and the center node c of the highest level aggregation area to which the node t belongs.
  • a flowchart of a shortest path query method provided by Embodiment 2 of the present invention includes:
  • S401 Perform area aggregation on the nodes in the database, and save the formed first-level aggregation area network in the hierarchical virtual node memory.
  • the hierarchical virtual node memory to be used may also be initialized, for example, initializing the visited node list, the node table corresponding to each aggregation area of each level, and the shortest path record between different nodes;
  • the aggregation area network includes the nodes included in each aggregation area, the relationship between the different nodes, and the like.
  • the above-mentioned N value may be directly set, or after the area aggregation is performed, the number of areas after the aggregation may be determined. After the number of the areas after the aggregation is less than the set threshold, the area aggregation is stopped.
  • S403 Determine a shortest path between central nodes of different highest level aggregation areas, and save in a shortest path retrieval processor;
  • the shortest path query device corresponding to the shortest path query method is also provided in the embodiment of the present invention. Since the principle of solving the problem is similar to the method of the embodiment of the present invention, the implementation of the device may refer to the method. Implementation, repetition will not be repeated.
  • FIG. 5 it is a structural diagram of a shortest path query device according to Embodiment 1 of the present invention, which includes: a first determining module 51, configured to determine and store an aggregation area of each level to which each node in the database belongs, And a shortest path between each node and a central node of the aggregation area of each level to which it belongs, and a shortest path between the central nodes of the aggregation areas of different highest levels; wherein, the high-level aggregation area includes multiple different a low-level aggregation area; for any level of aggregation area, the adjacent aggregation area includes at most one common node or at most one aggregation area lower than the arbitrary one level;
  • the second determining module 52 is configured to determine a shortest path between the two nodes in the query request according to the stored aggregated area and the shortest path.
  • the first determining module 51 is specifically configured to:
  • the first determining module 51 is specifically configured to determine, according to the following steps, an aggregation area of an Nth level to which each node in the database belongs, where N is a positive integer greater than one,
  • Each N-1th-level aggregation area is an N-1th-level virtual node, and accesses an un-accessed degree N-1-level virtual node in the database, and the largest degree
  • the virtual node of the N-1th level has all the N-1th virtual nodes of the directly connected side, and the virtual node of the N-1th level with the highest degree of access and the Nth with the largest degree All virtual nodes of the N-1 level of the -1 level virtual node have a directly connected edge to form an Nth level aggregation area;
  • the second determining module 52 is specifically configured to:
  • the shortest path between each node in the database and the central node of the associated high-level aggregation area is determined according to the determined shortest path between each node and the central node of the associated low-level aggregation area.
  • the second determining module 52 is further configured to determine, according to the stored aggregated area and the shortest path, the two nodes in the query request before determining the shortest path between the two nodes in the query request. There are no directly connected edges.
  • the second determining module 52 is specifically configured to:
  • the shortest path between the two nodes and the central node of the highest-level aggregation area, and the two The shortest path between the central nodes of the highest level aggregation area to which the nodes belong respectively is the shortest path between the two nodes;
  • the two nodes in the query request belong to the same highest-level aggregation area, it is determined whether there is a different M-th aggregation area to which the two nodes belong, where M is a positive integer, and the The M level is the highest level among the different aggregation levels of the same level to which the two nodes belong; if present, the two nodes are respectively associated with the central node of the aggregation area of the M+1th level to which the node belongs.
  • the shortest path is the shortest path between the two nodes, and if not, the shortest between the two nodes and the central node of the first-level aggregation area The path acts as the shortest path between the two nodes.
  • a schematic diagram of a shortest path query device includes: a processor 61, configured to determine an aggregation area of each level to which each node in the database belongs, and each node.
  • the shortest path between the central node of the aggregation area of each level of the respective level, and the shortest path between the central nodes of the aggregation area of the highest level, and the stored aggregated area and the shortest path are written into the memory 62, according to The aggregation area and the shortest path stored in the memory 62 determine the shortest path between the two nodes in the query request; wherein, the high-level aggregation area includes a plurality of different low-level aggregation areas; for any level of the aggregation area, The adjacent aggregation area includes at most one common node or at most one aggregation area lower than one level of any one of the levels;
  • the memory 62 is configured to store an aggregation area and a shortest path determined by the processor 61.
  • the processor 61 is specifically configured to:
  • the processor 61 is specifically configured to determine, according to the following steps, an aggregation area of an Nth level to which each node in the database belongs, where N is a positive integer greater than one,
  • Each N-1th-level aggregation area is an N-1th-level virtual node, and accesses an un-accessed degree N-1-level virtual node in the database, and the largest degree
  • the virtual node of the N-1th level has all the N-1th virtual nodes of the directly connected side, and the virtual node of the N-1th level with the highest degree of access and the Nth with the largest degree All virtual nodes of the N-1 level of the -1 level virtual node have a directly connected edge to form an Nth level aggregation area;
  • the processor 61 is specifically configured to:
  • the shortest path determines the shortest path between each node in the database and the central node of the associated high-level aggregation area.
  • the processor 61 is further configured to: before determining a shortest path between two nodes in the query request according to the stored aggregation area and the shortest path, determining that the two nodes in the query request are not between There are edges that are directly connected.
  • the processor 61 is specifically configured to:
  • the shortest path between the two nodes and the central node of the highest-level aggregation area, and the two The shortest path between the central nodes of the highest level aggregation area to which the nodes belong respectively is the shortest path between the two nodes;
  • the two nodes in the query request belong to the same highest-level aggregation area, it is determined whether there is a different third-level aggregation area to which the two nodes belong, where ⁇ is a positive integer, and the The ⁇ level is the highest level among the different aggregation levels of the same level to which the two nodes belong; if present, the two nodes are respectively associated with the central node of the aggregation area of the M+1th level to which it belongs.
  • the shortest path is the shortest path between the two nodes. If not, the shortest path between the two nodes and the central node of the first-level aggregation area of the first level is used as the two nodes. The shortest path between.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can be embodied in the form of one or more computer program products embodied on a computer-usable storage medium (including but not limited to disk storage, CD-ROM, optical storage, etc.) in which computer usable program code is embodied.
  • a computer-usable storage medium including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明涉及信息技术领域,尤其涉及一种最短路径查询方法及装置,用以解决现有技术中预先计算并存储数据库中所有节点间的最短路径的方式耗费存储空间较大的问题;本发明的方法包括:确定并存储数据库中的每个节点分别所属的每一级别的聚合区域,以及每个节点分别与所属的每一级别的聚合区域的中心节点之间的最短路径,和不同最高级别的聚合区域的中心节点之间的最短路径;根据存储的聚合区域及最短路径,确定查询请求中的两个节点之间的最短路径。本发明方法所需存储空间较小,且根据存储的聚合区域和最短路径就可以确定查询请求中的两个节点之间的最短路径,查询效率较高。

Description

一种最短路径查询方法及装置
技术领域
本发明涉及信息技术领域, 尤其涉及一种最短路径查询方法及装置。 背景技术
确定节点间的最短路径是在数据库应用中基本的操作需求, 传统获取最 短路径的方式是在查询数据库时临时计算最短路径, 但是, 随着数据库中的 图数据规模的增长, 釆用传统方式获取最短路径时, 无法一次通过内存读取 整个数据库中的图数据, 这样很多传统的基于内存的图算法都需要重新进行 调整, 每次只能加载一部分需要的图数据进行计算, 而不是一次加载整个数 据库中的图数据, 严重降低了查询效率。
为了解决上述传统方式查询效率低的问题, 开始对数据库中的图数据进 行预先处理, 比较普遍的一种方式是预先计算并存储数据库中所有节点间的 最短路径; 但是, 这种方式将耗费巨大的存储空间, 甚至导致存储器件, 如 内存、 硬盘等溢出, 影响正常工作流程。 发明内容
本发明提供一种最短路径查询方法及装置, 用以解决预先计算并存储数 据库中所有节点间的最短路径的方式, 耗费存储空间较大的问题。
第一方面, 提供一种最短路径查询方法, 包括:
确定并存储数据库中的每个节点分别所属的每一级别的聚合区域, 以及 每个节点分别与所属的每一级别的聚合区域的中心节点之间的最短路径, 和 不同最高级别的聚合区域的中心节点之间的最短路径; 其中, 高级别的聚合 区域包含多个不同的低级别的聚合区域; 针对任意一级别的聚合区域, 相邻 的聚合区域最多包括一个公共节点或最多包括一个比所述任意一级别低一级 别的聚合区域;
根据存储的聚合区域及最短路径, 确定查询请求中的两个节点之间的最 短路径。
结合第一方面, 在第一种可能的实现方式中, 确定数据库中的每个节点 分别所属的第一级别的聚合区域, 包括:
访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有节点。
结合第一方面的第一种可能的实现方式, 在第二种可能的实现方式中, 确定数据库中的每个节点分别所属的第 N级别的聚合区域, N为大于 1的正 整数, 包括:
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。 结合第一方面, 或第一方面的第一或第二种可能的实现方式, 在第三种 可能的实现方式中, 确定数据库中的每个节点分别与所属的每一级别的聚合 区域的中心节点之间的最短路径, 包括:
根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
结合第一方面, 或第一方面的第一至三种任意一种可能的实现方式, 在 第四种可能的实现方式中, 根据存储的聚合区域及最短路径, 确定查询请求 中的两个节点之间的最短路径之前, 还包括:
确定所述查询请求中的两个节点之间不存在直接连接的边。 结合第一方面, 或第一方面的第一至四种任意一种可能的实现方式, 在 第五种可能的实现方式中, 根据存储的聚合区域及最短路径, 确定查询请求 中的两个节点之间的最短路径, 包括:
若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径, 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径;
若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 M级别的聚合区域, 其中, M为 正整数, 所述第 M级别为所述两个节点所属的不同的同一级别的聚合区域中 的最高级别; 若存在, 则将所述两个节点分别与所属的第 M+1级别的聚合区 域的中心节点之间的最短路径作为所述两个节点之间的最短路径, 若不存在, 则将所述两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短 路径作为所述两个节点之间的最短路径。
第二方面, 提供一种最短路径查询装置, 其特征在于, 该装置包括: 第一确定模块, 用于确定并存储数据库中的每个节点分别所属的每一级 别的聚合区域, 以及每个节点分别与所属的每一级别的聚合区域的中心节点 之间的最短路径, 和不同最高级别的聚合区域的中心节点之间的最短路径; 其中, 高级别的聚合区域包含多个不同的低级别的聚合区域; 针对任意一级 别的聚合区域, 相邻的聚合区域最多包括一个公共节点或最多包括一个比所 述任意一级别低一级别的聚合区域;
第二确定模块, 用于根据存储的聚合区域及最短路径, 确定查询请求中 的两个节点之间的最短路径。
结合第二方面, 在第一种可能的实现方式中, 所述第一确定模块具体用 于:
访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域; 重复上述步骤, 直到访问完数据库中的所有节点。
结合第二方面的第一种可能的实现方式, 在第二种可能的实现方式中, 所述第一确定模块具体用于根据以下步骤确定数据库中的每个节点分别所属 的第 N级别的聚合区域, N为大于 1的正整数,:
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。 结合第二方面, 或第二方面的第一或第二种可能的实现方式, 在第三种 可能的实现方式中, 所述第二确定模块具体用于:
根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
结合第二方面, 或第二方面的第一至三种任意一种可能的实现方式, 在 第四种可能的实现方式中, 所述第二确定模块还用于, 根据存储的聚合区域 及最短路径, 确定查询请求中的两个节点之间的最短路径之前, 确定所述查 询请求中的两个节点之间不存在直接连接的边。
结合第二方面, 或第二方面的第一至四种任意一种可能的实现方式, 在 第五种可能的实现方式中, 所述第二确定模块具体用于:
若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径, 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径; 若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 M级别的聚合区域, 其中, M为 正整数, 所述第 M级别为所述两个节点所属的不同的同一级别的聚合区域中 的最高级别; 若存在, 则将所述两个节点分别与所属的第 M+1级别的聚合区 域的中心节点之间的最短路径作为所述两个节点之间的最短路径, 若不存在, 则将所述两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短 路径作为所述两个节点之间的最短路径。
本发明中确定并存储数据库中的每个节点分别所属的每一级别的聚合区 域, 以及每个节点分别与所属的每一级别的聚合区域的中心节点之间的最短 路径, 和不同最高级别的聚合区域的中心节点之间的最短路径, 根据存储的 聚合区域及最短路径, 确定查询请求中的两个节点之间的最短路径; 本发明 中预先存储的聚合区域占用存储空间较小, 且存储的最短路径只是每个节点 分别与所属的聚合区域的中心节点之间的最短路径以及最高级别的聚合区域 的中心节点之间的最短路径, 因此所需的存储空间也较小; 釆用本发明方法, 根据存储的聚合区域及最短路径, 就可以确定查询请求中的两个节点之间的 最短路径, 查询效率较高。 附图说明
图 1为本发明实施例一提供的最短路径查询方法流程图;
图 2为本发明实施例第一级别的聚合区域形成的示意图;
图 3为本发明实施例第二级别的聚合区域形成的示意图;
图 4为本发明实施例二提供的最短路径查询方法流程图;
图 5所示, 为本发明实施例一提供的最短路径查询装置结构图; 图 6所示, 为本发明实施例二提供的最短路径查询装置结构图。 具体实施方式
本发明实施例中确定并存储数据库中的每个节点分别所属的每一级别的 聚合区域, 以及每个节点分别与所属的每一级别的聚合区域的中心节点之间 的最短路径, 和不同最高级别的聚合区域的中心节点之间的最短路径, 根据 存储的聚合区域及最短路径, 确定查询请求中的两个节点之间的最短路径; 本发明实施例中, 预先存储的聚合区域占用存储空间较小, 且存储的最短路 径只是每个节点分别与所属的聚合区域的中心节点之间的最短路径以及最高 级别的聚合区域的中心节点之间的最短路径, 因此所需的存储空间也较小; 釆用本发明实施例的方法, 根据存储的聚合区域及最短路径, 就可以确定查 询请求中的两个节点之间的最短路径, 查询效率较高。
下面结合说明书附图对本发明实施例作进一步详细描述。
如图 1 所示, 为本发明实施例一提供的最短路径查询方法流程图, 包括 以下步骤:
S101 : 确定并存储数据库中的每个节点分别所属的每一级别的聚合区域, 以及每个节点分别与所属的每一级别的聚合区域的中心节点之间的最短路 径, 和不同最高级别的聚合区域的中心节点之间的最短路径; 其中, 高级别 的聚合区域包含多个不同的低级别的聚合区域; 针对任意一级别的聚合区域, 相邻的聚合区域最多包括一个公共节点或最多包括一个比所述任意一级别低 一级别的聚合区域;
S102: 根据存储的聚合区域及最短路径, 确定查询请求中的两个节点之 间的最短路径。
在具体实施过程中, 可以将数据库中的节点划分为一个级别或多个级别 的聚合区域, 即对数据库中的节点进行一个级别或多个级别的区域聚合, 其 中, 高级别的聚合区域是在低级别的聚合区域的基础上进行聚合的, 每一级 别的每个聚合区域都存在一个中心节点, 第一级别的聚合区域由中心节点和 该中心节点的邻居节点组成, 第 N级别的聚合区域是由中心的第 N-1级别的 聚合区域和该中心的第 N-1级别的聚合区域的第 N-1级别的邻居聚合区域组 成;
根据上述确定并存储的聚合区域和最短路径, 可以确定查询请求中的两 个节点之间的最短路径, 比如, 假设查询请求中的两个节点为同一个第一级 别的聚合区域中的非中心节点, 且它们之间不存在直接连接的边, 则可以将 这两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短路径作 为这两个节点之间的最短路径。
可选地, 步骤 S101中, 确定数据库中的每个节点分别所属的第一级别的 聚合区域, 包括:
访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有节点。
在具体实施中, 可以从数据库中选取一个未被访问的度最大的节点, 由 该度最大的节点及与该度最大的节点存在直接连接的边的节点组成一个第一 级别的聚合区域; 重复执行该步骤, 直到数据库中的所有节点都有所属的第 一级别的聚合区域后, 即可得到所有第一级别的聚合区域。
如图 2所示, 为第一级别的聚合区域形成的示意图, 首先, 从数据库中 选取一个未被访问的度最大的节点 1 ,由该节点 1及与该节点 1存在直接连接 的边的节点 2〜Ί组成一个第一级别的聚合区域 Γ , 继续从剩余的未被访问的 节点中选取一个度最大的节点 8,由该节点 8及与该节点 8存在直接连接的边 的节点 9~13 , 组成第二个第一级别的聚合区域 8', 继续从剩余的未被访问的 节点中选取一个度最大的节点 14, 由该节点 14及与该节点 14存在直接连接 的边的节点 15~20组成第三个第一级别的聚合区域 14', 如此, 形成第一级别 的聚合区域 1'、 8'、 14' , 这三个聚合区域形成第一级别的聚合区域网络, 在 具体实施过程中, 若两个不同的第一级别的聚合区域之间存在公共节点或直 接连接的边, 则在聚合后的区域网络中, 在这两个聚合区域之间记录一条边。 在第一级别的聚合区域中, 各非中心节点与中心节点之间的最短路径即为各 非中心节点与中心节点的直接连接的边, 因此, 存储了第一级别的聚合区域 网络, 也即存储了每个第一级别的聚合区域所包括的中心节点和非中心节点 后, 也就相当于存储了各非中心节点到中心节点的最短路径;
本发明实施例中, 最短路径对应的路径长度即为最短距离, 也即, 若节 点之间直接连接的边对应的距离为 1 , 则图 2中, 各非中心节点与中心节点之 间的最短距离为 1 ; 本发明实施例中, 若只将数据库中的节点划分为一个级别 的聚合区域, 也即第一级别的聚合区域, 则在根据查询请求确定两个节点之 间的最短路径时, 若两个节点之间存在直接连接的边, 则该直接连接的边可 作为它们之间的最短路径, 如图 2中, 节点 5和节点 15之间存在直接连接的 边, 它们之间的最短路径即为 5^15; 若两个节点分别为相同的第一级别的聚 合区域的非中心节点, 且它们之间不存在直接连接的边, 则它们之间的最短 路径为它们分别与所属的第一级别的聚合区域的中心节点之间的最短路径, 如图 2中, 节点 2和节点 3之间的最短路径即为 2^1^3; 若这两个节点分别 为不同的第一级别的聚合区域中的节点, 且它们之间不存在直接连接的边, 则它们之间的最短路径为它们分别与所属的第一级别的聚合区域的中心节点 之间的最短路径, 以及它们分别所属的第一级别的聚合区域的中心节点之间 的最短路径,如图 2中,节点 2和节点 10之间的最短路径即为 2 1 4 8 10。
若将数据库中的节点划分为多个级别的聚合区域, 可继续釆用下述方式 对第一级别的聚合区域进行聚合;
具体地, 确定数据库中的每个节点分别所属的第 Ν级别的聚合区域, Ν 为大于 1的正整数, 包括:
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 Ν级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。 在具体实施中, 可以从数据库中选取一个未被访问的度最大的第 N-1 级 别的虚拟节点, 由该度最大的第 N-1 级别的虚拟节点及与该度最大的第 N-1 级别的虚拟节点存在直接连接的边的第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域; 重复执行该步骤, 直到数据库中的所有第 N-1 级别的虚拟节 点都有所属的第 N级别的聚合区域后, 即可得到所有第 N级别的聚合区域; 在具体实施中, 可以布置分层虚拟节点存储器, 在分层虚拟节点存储器 中存储每一级别的聚合区域, 以及每个聚合区域内各节点与聚合区域的中心 节点之间的最短路径; 在实施中, 可根据实际需要直接设置上述 N值, 也可 以在数据库对应的区域数目小于设定阔值时, 停止进行区域聚合。
如图 3 所示, 为第二级别的聚合区域形成的示意图, 以第一级别的聚合 区域 1'、 8'、 14'分别为三个虚拟节点, 从数据库中选取一个未被访问的度最 大的虚拟节点 Γ, 由该虚拟节点 Γ及与该虚拟节点 Γ存在直接连接的边的虚 拟节点 8'和 14'组成一个第二级别的聚合区域 Γ; 从图中可知, 第二级别的聚 合区域 Γ的中心节点即为第一级别的聚合区域 Γ的中心节点 1;
在确定各节点分别与所属的第二级别的聚合区域的中心节点之间的最短 路径时, 若第一级别的中心聚合区域和它的邻居聚合区域之间存在公共节点, 如 Γ与 8'之间存在公共节点 4,则该第一级别的邻居聚合区域的中心节点与所 属的第二级别的聚合区域的中心节点之间的最短路径为该第一级别的邻居聚 合区域的中心节点与所述公共节点之间的最短路径、 以及所述公共节点与所 述第二级别的聚合区域的中心节点之间的最短路径, 如 8'的中心节点 8与 Γ 的中心节点 1之间的最短路径为 8 4 1 , 将每条边的距离记为 1 , 则最短距 离为 2, 同时, 除公共节点外, 该第一级别的邻居聚合区域的非中心节点与所 属的第二级别的聚合区域的中心节点之间的最短路径为上述得到的该第一级 别的邻居聚合区域的中心节点与所属的第二级别的聚合区域的中心节点之间 的最短路径加上该第一级别的邻居聚合区域的非中心节点与该第一级别的邻 居聚合区域的中心节点之间的最短路径, 也即, 将该第一级别的邻居聚合区 域的非中心节点与该第一级别的邻居聚合区域的中心节点之间的最短路径、 该第一级别的邻居聚合区域的中心节点与所述公共节点之间的最短路径、 以 及所述公共节点与所述第二级别的聚合区域的中心节点之间的最短路径作为 该第一级别的邻居聚合区域的非中心节点与所属的第二级别的聚合区域的中 心节点之间的最短路径,如 8'的非中心节点 11与 Γ的中心节点 1之间的最短 路径为 11 8 4 1 , 最短距离为 2+1=3;
若第一级别的中心聚合区域和它的邻居聚合区域之间存在直接连接的 边, 如 Γ与 14'之间存在直接连接的边, 则该第一级别的邻居聚合区域的中心 节点与所属的第二级别的聚合区域的中心节点之间的最短路径为该第一级别 的邻居聚合区域的中心节点与该第一级别的邻居聚合区域中与第一级别的中 心聚合区域存在直接连接的边的节点之间的最短路径, 该直接连接的边, 以 及该直接连接的边对应的属于该第一级别的中心聚合区域的节点、 与该第二 级别的聚合区域的中心节点之间的最短路径, 如 14'的中心节点 14与 Γ的中 心节点 1之间的最短路径为 14 15 5 1 , 将每条边的距离记为 1 , 则最短 距离为 3 , 同时, 除该直接连接的边对应的节点外, 第一级别的邻居聚合区域 的非中心节点与所属的第二级别的聚合区域的中心节点之间的最短路径为上 述得到的第一级别的邻居聚合区域的中心节点与所属的第二级别的聚合区域 的中心节点之间的最短路径加上该第一级别的邻居聚合区域的非中心节点与 该第一级别的邻居聚合区域的中心节点之间的最短路径, 如 14'的非中心节点 18 与 1 "的中心节点 1 之间的最短路径为 18 14 15 5 1 , 最短距离为 3+1=4。
可选地, 确定数据库中的每个节点分别与所属的每一级别的聚合区域的 中心节点之间的最短路径, 包括:
根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
在具体实施中, 在确定出每个节点分别与所属的低级别的聚合区域的中 心节点之间的最短路径之后, 可以根据已确定的每个节点分别与所属的低级 别的聚合区域的中心节点之间的最短路径确定每个节点分别与所属的高级别 的聚合区域的中心节点的最短路径;
结合上述与图 3相关的说明, 根据确定的每个节点分别与比所属的第 N 级别的聚合区域级别低的聚合区域的中心节点之间的最短路径, 确定数据库 中的每个节点分别与所属的第 N级别的聚合区域的中心节点之间的最短路径 的方式可以有但不仅限于以下几种:
针对第 N级别的聚合区域中的任意一个节点, 若所述任意一个节点与所 述第 N级别的聚合区域的中心节点属于同一个第 N-1级别的聚合区域, 则将 所述任意一个节点与所属的第 N-1 级别的聚合区域的中心节点之间的最短路 径作为所述任意一个节点与所属的第 N级别的聚合区域的中心节点之间的最 短路径; 其中, N为大于 1的正整数;
若所述任意一个节点与所述第 N级别的聚合区域的中心节点不属于同一 个第 N-1级别的聚合区域, 且所述任意一个节点是所属的第 N-1级别的聚合 区域的中心节点, 则判断所述任意一个节点所属的第 N-1 级别的聚合区域与 所述第 N级别的聚合区域的中心节点所属的第 N-1级别的聚合区域之间是否 存在公共节点 (N=2 )或公共的第 N-2级别的聚合区域(N>2 ), 若存在, 则 将所述任意一个节点与所述公共节点或公共的第 N-2级别的聚合区域的中心 节点之间的最短路径、 以及所述公共节点或公共的第 N-2级别的聚合区域的 中心节点与所述第 N级别的聚合区域的中心节点之间的最短路径作为所述任 意一个节点与所属的第 N级别的聚合区域的中心节点之间的最短路径; 若不 存在, 则将属于不同的第 N-1 级别的聚合区域、 且存在直接直接连接的边的 两个节点分别与所属的第 N-1 级别的聚合区域的中心节点之间的最短路径、 以及所述直接直接连接的边作为所述任意一个节点与所属的第 N级别的聚合 区域的中心节点之间的最短路径;
若所述任意一个节点与所述第 N级别的聚合区域的中心节点不属于同一 个第 N-1级别的聚合区域, 且所述任意一个节点不是所属的第 N-1级别的聚 合区域的中心节点, 也不是所属的第 N-1级别的聚合区域与所述第 N级别的 聚合区域的中心节点所属的第 N-1 级别的聚合区域之间的直接连接的边所对 应的节点或对应的第 N-2级别的聚合区域中的节点, 则判断所述任意一个节 点所属的第 N-1级别的聚合区域与所述第 N级别的聚合区域的中心节点所属 的第 N-1级别的聚合区域之间是否存在公共节点或公共的第 N-2级别的聚合 区域, 若存在, 则将所述任意一个节点与所属的第 N-1 级别的聚合区域的中 心节点之间的最短路径、 所述任意一个节点所属的第 N-1 级别的聚合区域的 中心节点与所述公共节点或公共的第 N-2级别的聚合区域的中心节点之间的 最短路径、 以及所述公共节点或公共的第 N-2级别的聚合区域的中心节点与 所述第 N级别的聚合区域的中心节点之间的最短路径作为所述任意一个节点 与所属的第 N级别的聚合区域的中心节点之间的最短路径; 若不存在, 则将 属于不同的第 N-1 级别的聚合区域, 且存在直接连接的边的两个节点分别与 所属的第 N-1 级别的聚合区域的中心节点之间的最短路径、 所述直接连接的 边对应的两个节点之间的最短路径、 以及所述任意一个节点与所属的第 N-1 级别的聚合区域的中心节点之间的最短路径作为所述任意一个节点与所属的 第 N级别的聚合区域的中心节点之间的最短路径;
若所述任意一个节点是所属的第 N-1级别的聚合区域与所述第 N级别的 聚合区域的中心节点所属的第 N-1 级别的聚合区域之间的直接连接的边所对 应的节点, 则将所述直接连接的边、 以及所述直接连接的边所对应的另外一 个节点与所述第 N级别的聚合区域的中心节点之间的最短路径作为所述任意 一个节点与所属的第 N级别的聚合区域的中心节点之间的最短路径;
若 N>2, 则还可以存在以下确定方式:
若所述任意一个节点不是所属的第 N-1级别的聚合区域与所述第 N级别 的聚合区域的中心节点所属的第 N-1 级别的聚合区域之间的直接连接的边所 对应的节点, 但是所述任意一个节点所属的第 N-2级别的聚合区域中存在节 点是所述直接连接的边所对应的节点, 这时, 若 N=3 , 则可以将所述任意一 个节点与所属的第 N_2级别的聚合区域的中心节点之间的最短路径、 所述第 N-2级别的聚合区域的中心节点与所述第 N级别的聚合区域的中心节点之间 的最短路径, 作为所述任意一个节点与所属的第 N级别的聚合区域的中心节 点之间的最短路径; 若 N>3 , 则需要继续判断所述任意一个节点是否属于, 所述直接连边对应的节点所属的第 N-3 级别的聚合区域中的节点, 并根据判 断结果, 确定所述任意一个节点与所属的第 N级别的聚合区域的中心节点之 不再赘述。
可选地, 上述步骤 S102之前, 还包括:
确定所述查询请求中的两个节点之间不存在直接连接的边。
在具体实施过程中, 若确定查询请求中的两个节点之间存在直接连接的 边, 则可以将该直接连接的边作为两个节点之间的最短路径, 若两个节点之 间不存在直接连接的边, 则可以根据存储的最短路径, 确定查询请求中的两 个节点之间的最短路径。
可选地, 上述步骤 S102中, 根据存储的聚合区域及最短路径, 确定查询 请求中的两个节点之间的最短路径, 包括:
若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径、 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径;
这里, 所述查询请求中的两个节点之间的最短路径对应的最短距离用公 式表示为:
douter = d(s, c + ά^, ^) + d(c2, t);
上式中, d。uter为所述查询请求中的两个节点之间的最短距离, d(s, Cl)为 节点 s与所属的最高级别的聚合区域的中心节点 Cl之间的最短距离, d(Cl, c2) 为所述节点 s与节点 t分别所属的最高级别的聚合区域的中心节点 和(:2之间 的最短距离, d(c2, t)为节点 t与节点 t所属的最高级别的聚合区域的中心节点 c2 之间的最短距离。
若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 M级别的聚合区域, 其中, M为 正整数, 所述第 M级别的聚合区域为所述两个节点所属的不同的同一级别的 聚合区域中的最高级别; 若存在, 则将所述两个节点分别与所属的相同的第 M+1 级别的聚合区域的中心节点之间的最短路径作为所述两个节点之间的最 短路径, 若不存在, 则将所述两个节点分别与所属的相同的第一级别的聚合 区域的中心节点之间的最短路径作为所述两个节点之间的最短路径。
这里, 所述查询请求中的两个节点之间的最短路径对应的最短距离用公 式表示为:
dinner = d(S, C) + d(C, t) ;
上式中, dinner为所述查询请求中的两个节点之间的最短距离, d(s, c)为 节点 s与所属的最高级别的聚合区域的中心节点 c之间的最短距离, d(c, t)为节 点 t与节点 t所属的最高级别的聚合区域的中心节点 c之间的最短距离。
为了进一步说明本发明实施例进行最短路径查询的方法, 下面再列举一 个具体的实例:
如图 4所示, 为本发明实施例二提供的最短路径查询方法流程图, 包括:
S401 : 对数据库中的节点进行区域聚合, 将形成的第一级别的聚合区域 网络, 保存在分层虚拟节点存储器中;
在实施此步骤之前, 还可以将需要使用的分层虚拟节点存储器进行初始 化, 比如, 初始化已访问节点列表、 每一级别的每个聚合区域对应的节点表、 不同节点之间的最短路径记录; 这里的聚合区域网络包括每个聚合区域所包 括的节点、 不同节点之间的关系等, 具体进行区域聚合的过程可参见实施例 一的描述, 这里不再赘述。
S402: 以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 对 所有的虚拟节点进行区域聚合, 形成第 N级别的聚合区域网络, 将形成的第 N级别的聚合区域网络及每个第 N级别的聚合区域内各节点与该第 N级别的 聚合区域的中心节点之间的最短路径保存在分层虚拟节点存储器中;
初始时, N=2, 将 N加 1 , 重复上述步骤, 不断地对数据库中的节点进行 区域聚合, 直到在分层虚拟节点存储器中得到预定规模的区域网络; 在具体 实施中, 可以直接设置上述 N值, 也可以在进行区域聚合后, 判断聚合后的 区域数量大小, 在聚合后的区域数量小于设定阔值后, 停止进行区域聚合。
S403 : 确定不同的最高级别的聚合区域的中心节点之间的最短路径, 并 保存在最短路径检索处理器中;
S404: 在接收到查询请求后, 根据上述分层虚拟节点存储器中存储的每 一级别的聚合区域网络和各节点与所属的每一级别的聚合区域的中心节点之 间的最短路径, 及上述最短路径检索处理器中存储的最高级别的聚合区域的 中心节点之间的最短路径, 确定查询请求中的两个节点之间的最短路径; 具体根据存储的最短路径确定查询请求中的两个节点之间的最短路径的 过程可参见上述实施例一的描述, 这里不再赘述。
基于同一发明构思, 本发明实施例中还提供了与最短路径查询方法对应 的最短路径查询装置, 由于该装置解决问题的原理与本发明实施例方法部分 相似, 因此该装置的实施可以参见方法的实施, 重复之处不再赘述。
如图 5所示, 为本发明实施例一提供的最短路径查询装置结构图, 包括: 第一确定模块 51 , 用于确定并存储数据库中的每个节点分别所属的每一 级别的聚合区域, 以及每个节点分别与所属的每一级别的聚合区域的中心节 点之间的最短路径, 和不同最高级别的聚合区域的中心节点之间的最短路径; 其中, 高级别的聚合区域包含多个不同的低级别的聚合区域; 针对任意一级 别的聚合区域, 相邻的聚合区域最多包括一个公共节点或最多包括一个比所 述任意一级别低一级别的聚合区域;
第二确定模块 52, 用于根据存储的聚合区域及最短路径, 确定查询请求 中的两个节点之间的最短路径。
可选地, 所述第一确定模块 51具体用于:
访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有节点。 可选地, 所述第一确定模块 51具体用于根据以下步骤确定数据库中的每 个节点分别所属的第 N级别的聚合区域, N为大于 1的正整数,:
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。 可选地, 所述第二确定模块 52具体用于:
根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
可选地,所述第二确定模块 52还用于,根据存储的聚合区域及最短路径, 确定查询请求中的两个节点之间的最短路径之前, 确定所述查询请求中的两 个节点之间不存在直接连接的边。
可选地, 所述第二确定模块 52具体用于:
若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径, 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径;
若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 M级别的聚合区域, 其中, M为 正整数, 所述第 M级别为所述两个节点所属的不同的同一级别的聚合区域中 的最高级别; 若存在, 则将所述两个节点分别与所属的第 M+1级别的聚合区 域的中心节点之间的最短路径作为所述两个节点之间的最短路径, 若不存在, 则将所述两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短 路径作为所述两个节点之间的最短路径。
如图 6所示, 为本发明实施例二提供的最短路径查询装置结构图, 包括: 处理器 61 , 用于确定数据库中的每个节点分别所属的每一级别的聚合区 域, 以及每个节点分别与所属的每一级别的聚合区域的中心节点之间的最短 路径, 和不同最高级别的聚合区域的中心节点之间的最短路径, 并将存储的 聚合区域和最短路径写入存储器 62,根据存储器 62存储的聚合区域及最短路 径, 确定查询请求中的两个节点之间的最短路径; 其中, 高级别的聚合区域 包含多个不同的低级别的聚合区域; 针对任意一级别的聚合区域, 相邻的聚 合区域最多包括一个公共节点或最多包括一个比所述任意一级别低一级别的 聚合区域;
存储器 62, 用于存储所述处理器 61确定的聚合区域和最短路径。
可选地, 所述处理器 61具体用于:
访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有节点。
可选地, 所述处理器 61具体用于根据以下步骤确定数据库中的每个节点 分别所属的第 N级别的聚合区域, N为大于 1的正整数,:
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。 可选地, 所述处理器 61具体用于:
根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
可选地, 所述处理器 61还用于, 根据存储的聚合区域及最短路径, 确定 查询请求中的两个节点之间的最短路径之前, 确定所述查询请求中的两个节 点之间不存在直接连接的边。
可选地, 所述处理器 61具体用于:
若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径, 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径;
若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 Μ级别的聚合区域, 其中, Μ为 正整数, 所述第 Μ级别为所述两个节点所属的不同的同一级别的聚合区域中 的最高级别; 若存在, 则将所述两个节点分别与所属的第 M+1级别的聚合区 域的中心节点之间的最短路径作为所述两个节点之间的最短路径, 若不存在, 则将所述两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短 路径作为所述两个节点之间的最短路径。
本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或 计算机程序产品。 因此, 本发明可釆用完全硬件实施例、 完全软件实施例、 或结合软件和硬件方面的实施例的形式。 而且, 本发明可釆用在一个或多个 其中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘 存储器、 CD-ROM、 光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、 装置(系统)、 和计算机程序产 品的流程图和 /或方框图来描述的。 应理解可由计算机程序指令实现流程图 和 /或方框图中的每一流程和 /或方框、 以及流程图和 /或方框图中的流程 和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器, 使得通 过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流 程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的 装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设 备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存储器 中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个流程或 多个流程和 /或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的 处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图 一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的步 骤。
尽管已描述了本发明的优选实施例, 但本领域内的技术人员一旦得知了 基本创造性概念, 则可对这些实施例作出另外的变更和修改。 所以, 所附权 利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。 发明的精神和范围。 这样, 倘若本发明的这些修改和变型属于本发明权利要 求及其等同技术的范围之内, 则本发明也意图包含这些改动和变型在内。

Claims

权 利 要 求
1、 一种最短路径查询方法, 其特征在于, 该方法包括:
确定并存储数据库中的每个节点分别所属的每一级别的聚合区域, 以及 每个节点分别与所属的每一级别的聚合区域的中心节点之间的最短路径, 和 不同最高级别的聚合区域的中心节点之间的最短路径; 其中, 高级别的聚合 区域包含多个不同的低级别的聚合区域; 针对任意一级别的聚合区域, 相邻 的聚合区域最多包括一个公共节点或最多包括一个比所述任意一级别低一级 别的聚合区域;
根据存储的聚合区域及最短路径, 确定查询请求中的两个节点之间的最 短路径。
2、 如权利要求 1所述的方法, 其特征在于, 确定数据库中的每个节点分 别所属的第一级别的聚合区域, 包括:
访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有节点。
3、 如权利要求 2所述的方法, 其特征在于, 确定数据库中的每个节点分 别所属的第 N级别的聚合区域, N为大于 1的正整数, 包括:
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。
4、 如权利要求 1~3任一所述的方法, 其特征在于, 确定数据库中的每个 节点分别与所属的每一级别的聚合区域的中心节点之间的最短路径, 包括: 根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
5、 如权利要求 1~4任一所述的方法, 其特征在于, 根据存储的聚合区域 及最短路径, 确定查询请求中的两个节点之间的最短路径之前, 还包括: 确定所述查询请求中的两个节点之间不存在直接连接的边。
6、 如权利要求 1~5任一所述的方法, 其特征在于, 根据存储的聚合区域 及最短路径, 确定查询请求中的两个节点之间的最短路径, 包括:
若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径, 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径;
若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 M级别的聚合区域, 其中, M为 正整数, 所述第 M级别为所述两个节点所属的不同的同一级别的聚合区域中 的最高级别; 若存在, 则将所述两个节点分别与所属的第 M+1级别的聚合区 域的中心节点之间的最短路径作为所述两个节点之间的最短路径, 若不存在, 则将所述两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短 路径作为所述两个节点之间的最短路径。
7、 一种最短路径查询装置, 其特征在于, 该装置包括:
第一确定模块, 用于确定并存储数据库中的每个节点分别所属的每一级 别的聚合区域, 以及每个节点分别与所属的每一级别的聚合区域的中心节点 之间的最短路径, 和不同最高级别的聚合区域的中心节点之间的最短路径; 其中, 高级别的聚合区域包含多个不同的低级别的聚合区域; 针对任意一级 别的聚合区域, 相邻的聚合区域最多包括一个公共节点或最多包括一个比所 述任意一级别低一级别的聚合区域; 第二确定模块, 用于根据存储的聚合区域及最短路径, 确定查询请求中 的两个节点之间的最短路径。
8、如权利要求 7所述的装置, 其特征在于, 所述第一确定模块具体用于: 访问数据库中的一个未被访问的度最大的节点, 及与所述度最大的节点 存在直接连接的边的所有节点, 并将访问的所述度最大的节点及与所述度最 大的节点存在直接连接的边的所有节点组成一个第一级别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有节点。
9、 如权利要求 8所述的装置, 其特征在于, 所述第一确定模块具体用于 根据以下步骤确定数据库中的每个节点分别所属的第 N级别的聚合区域, N 为大于 1的正整数;
以每个第 N-1级别的聚合区域为一个第 N-1级别的虚拟节点, 访问数据 库中的一个未被访问的度最大的第 N-1 级别的虚拟节点, 及与所述度最大的 第 N-1级别的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点, 并 将访问的所述度最大的第 N-1级别的虚拟节点及与所述度最大的第 N-1级别 的虚拟节点存在直接连接的边的所有第 N-1级别的虚拟节点组成一个第 N级 别的聚合区域;
重复上述步骤, 直到访问完数据库中的所有第 N-1级别的虚拟节点。
10、 如权利要求 Ί〜9任一所述的装置, 其特征在于, 所述第二确定模块 具体用于:
根据确定的每个节点分别与所属的低级别的聚合区域的中心节点之间的 最短路径, 确定数据库中的每个节点分别与所属的高级别的聚合区域的中心 节点之间的最短路径。
11、 如权利要求 7~10任一所述的装置, 其特征在于, 所述第二确定模块 还用于, 根据存储的聚合区域及最短路径, 确定查询请求中的两个节点之间 的最短路径之前, 确定所述查询请求中的两个节点之间不存在直接连接的边。
12、 如权利要求 7~11任一所述的装置, 其特征在于, 所述第二确定模块 具体用于: 若确定所述查询请求中的两个节点属于不同的最高级别的聚合区域, 则 将所述两个节点分别与所属的最高级别的聚合区域的中心节点之间的最短路 径, 以及所述两个节点分别所属的最高级别的聚合区域的中心节点之间的最 短路径作为所述两个节点之间的最短路径;
若确定所述查询请求中的两个节点属于相同的最高级别的聚合区域, 则 判断是否存在所述两个节点所属的不同的第 M级别的聚合区域, 其中, M为 正整数, 所述第 M级别为所述两个节点所属的不同的同一级别的聚合区域中 的最高级别; 若存在, 则将所述两个节点分别与所属的第 M+1级别的聚合区 域的中心节点之间的最短路径作为所述两个节点之间的最短路径, 若不存在, 则将所述两个节点分别与所属的第一级别的聚合区域的中心节点之间的最短 路径作为所述两个节点之间的最短路径。
PCT/CN2014/078134 2013-09-30 2014-05-22 一种最短路径查询方法及装置 WO2015043208A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310462558.7 2013-09-30
CN201310462558.7A CN104518965B (zh) 2013-09-30 2013-09-30 一种最短路径查询方法及装置

Publications (1)

Publication Number Publication Date
WO2015043208A1 true WO2015043208A1 (zh) 2015-04-02

Family

ID=52741956

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/078134 WO2015043208A1 (zh) 2013-09-30 2014-05-22 一种最短路径查询方法及装置

Country Status (2)

Country Link
CN (1) CN104518965B (zh)
WO (1) WO2015043208A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105005627A (zh) * 2015-08-07 2015-10-28 上海交通大学 基于Spark分布式系统的最短路径关键点查询方法
CN117171401B (zh) * 2023-11-03 2024-01-26 之江实验室 基于分层预计算的图数据中最短路径的查询方法和装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101232517A (zh) * 2008-01-31 2008-07-30 北京航空航天大学 地理位置无关的多汇聚节点部署方法
CN101330457A (zh) * 2008-07-24 2008-12-24 安徽大学 一种基于商空间覆盖模型的最短路径搜索方法
CN101969458A (zh) * 2010-11-26 2011-02-09 西安电子科技大学 支持层次化网络拓扑的p2p流量优化方法
CN103177382A (zh) * 2013-03-19 2013-06-26 武汉大学 微博平台上的关键传播路径和中心节点的探测方法

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101360051B (zh) * 2008-07-11 2011-07-20 西安电子科技大学 一种能量高效的无线传感器网络路由方法
US20100141531A1 (en) * 2008-12-08 2010-06-10 Hong Soon Nam Position tracking apparatus and method for a low power wpan/wban device
JP5178645B2 (ja) * 2009-06-30 2013-04-10 バブコック日立株式会社 複数経路の探索装置及び方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101232517A (zh) * 2008-01-31 2008-07-30 北京航空航天大学 地理位置无关的多汇聚节点部署方法
CN101330457A (zh) * 2008-07-24 2008-12-24 安徽大学 一种基于商空间覆盖模型的最短路径搜索方法
CN101969458A (zh) * 2010-11-26 2011-02-09 西安电子科技大学 支持层次化网络拓扑的p2p流量优化方法
CN103177382A (zh) * 2013-03-19 2013-06-26 武汉大学 微博平台上的关键传播路径和中心节点的探测方法

Also Published As

Publication number Publication date
CN104518965A (zh) 2015-04-15
CN104518965B (zh) 2018-04-20

Similar Documents

Publication Publication Date Title
TWI695260B (zh) 區塊資料校驗方法和裝置
WO2017076184A1 (zh) 分布式文件系统中的数据写入方法和装置
JP5943095B2 (ja) 複合不揮発性記憶装置のためのデータ移行
CN102929786B (zh) 非易失性存储设备集合的易失性存储器表示
TWI606337B (zh) 非依電性記憶體裝置及其垃圾收集方法
TW201837754A (zh) 基於區塊鏈的資料處理方法及設備
WO2017092480A1 (zh) 一种数据迁移的方法及装置
WO2017143957A1 (zh) 一种数据重分布的方法及装置
KR20060049710A (ko) 칩 멀티-프로세서의 공유 캐시를 분할하기 위한 장치 및방법
WO2014101420A1 (zh) 一种元数据的构建系统及其方法
CN104054071A (zh) 访问存储设备的方法和存储设备
US10482033B2 (en) Method and device for controlling memory
WO2021174763A1 (zh) 基于查找表的数据库管理方法和装置
US9063667B2 (en) Dynamic memory relocation
CN112988066A (zh) 一种数据处理方法及装置
WO2018121407A1 (zh) 防止Mongos集群中的均衡操作失效的方法和装置
US7792966B2 (en) Zone control weights
CN107153512A (zh) 一种数据迁移方法和装置
US20180205665A1 (en) Storage Device Access Mediation
WO2015043208A1 (zh) 一种最短路径查询方法及装置
WO2010012196A1 (zh) 一种数据读写的方法和装置
WO2024000897A1 (zh) 一种基于区块链的数字资产合成方法及装置
CN110069466A (zh) 一种面向分布式文件系统的小文件存储方法及装置
WO2023045250A1 (zh) 一种内存池资源共用的方法、装置、设备及可读介质
CN105630702A (zh) 一种逻辑卷创建方法与系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14849231

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14849231

Country of ref document: EP

Kind code of ref document: A1