WO2015043385A1 - Method and apparatus for reducing network flow graph - Google Patents

Method and apparatus for reducing network flow graph Download PDF

Info

Publication number
WO2015043385A1
WO2015043385A1 PCT/CN2014/086482 CN2014086482W WO2015043385A1 WO 2015043385 A1 WO2015043385 A1 WO 2015043385A1 CN 2014086482 W CN2014086482 W CN 2014086482W WO 2015043385 A1 WO2015043385 A1 WO 2015043385A1
Authority
WO
WIPO (PCT)
Prior art keywords
network
submap
node
flow graph
nodes
Prior art date
Application number
PCT/CN2014/086482
Other languages
French (fr)
Chinese (zh)
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 WO2015043385A1 publication Critical patent/WO2015043385A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations

Definitions

  • the embodiments of the present invention relate to the field of graph theory and combination optimization of algorithms, and in particular, to a network stream graph reduction method and apparatus.
  • the maximum flow minimum cut problem is a classic problem in graph theory and combinatorial optimization, such as local community discovery of social networks, Sybil attack defense system, online content voting system, Google's advertising system, spam discovery, computer vision, VLSI layout design.
  • Applications such as aircraft flight schedules and DNA multi-sequence comparisons can be modeled as maximum flow minimum cut algorithms.
  • the maximum flow is the maximum flow of each edge between the nodes in a directed graph, wherein the maximum flow from the source node is the maximum flow of the directed graph, and the maximum flow into the junction is the For the maximum flow to the graph, the inflow of the remaining nodes is equal to the outflow, and the flow rate of each edge between the nodes cannot exceed the capacity limit.
  • the directed graph In the directed graph, some edges are removed, so that the directed graph becomes two unconnected subgraphs, and the source point and the sink point are respectively in different subgraphs, and each subgraph can be called a cut, removed.
  • the sum of the flows of these edges is the cut capacity
  • the minimum cut is the cut with the smallest cut capacity
  • the maximum flow value is equal to the minimum cut capacity.
  • the scale of the directed graph can be reduced by reducing the number of nodes and edges in the directed graph, that is, the method based on the node pattern matching is used to reduce the scale of the directed graph, that is, to observe the directed graph.
  • the structure if some of the nodes' patterns conform to the preset mode, the nodes can be combined into one node, thereby reducing the scale of the directed graph.
  • the embodiment of the invention provides a network flow graph reduction method and device, which is used for effectively reducing the scale of the graph, and does not require the network flow graph to be processed to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
  • an embodiment of the present invention provides a network flow graph reduction method, including: acquiring a first network stream submap from a to-be-processed network flow graph, where the first network stream submap includes M nodes and M An edge between nodes, wherein the M nodes include a first endpoint, the M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes N nodes and N nodes
  • the N nodes include a source node and a sink node, the N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is used a starting node of the network flow indicating the network flow graph to be processed, the sink point being an end node of the network flow, wherein an edge between each node represents a network between each node Flow relationship
  • the second network proxy submap is Determining, in the processing network flow graph, all remaining nodes except the first network stream submap and edge components between the remaining nodes; all nodes and locations of the first network stream submap
  • An edge between all nodes of the second network stream submap becomes an edge between the first node and all nodes of the second network stream submap
  • the first reduced network flow graph includes a first node, the second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum of the first reduced network flow graph
  • the cut capacity is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
  • the combining the first part of the to-be-processed network flow diagram into a first node includes:
  • the M nodes are aggregated into one of the first nodes.
  • the obtaining, by the network flow graph to be processed, the first network flow sub-map includes:
  • the third network stream submap includes an edge between the preset number of nodes acquired by the search and the preset number of nodes acquired by the search, where the preset number is greater than or equal to The M;
  • a fifth network stream submap Forming, by the second node and the third network stream submap, a fifth network stream submap, where all nodes of the fourth network stream submap and all nodes of the third network stream submap An edge between the second node and all nodes of the third network stream submap, the fifth network stream submap including the second node, the third network a stream submap and an edge between the second node and all nodes of the third network stream submap, the second node being a second endpoint of the fifth network stream submap;
  • the second endpoint when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node;
  • the fourth possibility in the first aspect in conjunction with the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect, the fourth possibility in the first aspect
  • the method further includes :
  • the first reduced network flow graph is updated to the to-be-processed network flow graph.
  • the method also includes:
  • the sixth network stream submap includes edges between K nodes and K nodes, where K is greater than or equal to 2 An integer, wherein the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node The second endpoint is a source node;
  • the second reduced network flow graph includes the seventh network stream submap, the third node, and all nodes of the third node and the seventh network stream submap Between the edges, the minimum cut capacity of the second reduced network flow graph is equal to the minimum cut capacity of the first reduced network flow graph, and the third node is the second reduced network flow graph Two endpoints.
  • the method further includes:
  • an eighth possible implementation manner of the first aspect if the reduced number of times of the first reduced network flow graph is less than a second preset number of times, The second reduced network flow graph is updated to the first reduced network flow graph.
  • an embodiment of the present invention provides a network flow graph reduction device, including:
  • An acquiring unit configured to obtain a first network stream sub-picture from a to-be-processed network flow graph, where the first network stream sub-picture includes an edge between the M nodes and the M nodes, where the M nodes are Including a first endpoint, the M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes N junctions An edge between the point and the N nodes, wherein the N nodes include a source node and a sink node, the N is an integer greater than M, and the first endpoint is a source node or a sink node
  • the source node is a starting node of the network flow for indicating the network flow graph to be processed, and the sink node is an ending node of the network flow, wherein an edge between each node Indicates the network flow relationship between nodes;
  • a merging unit configured to merge the first network stream sub-graph obtained by the acquiring unit into a first node
  • a processing unit configured to combine the first node obtained by combining the merging unit with a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow
  • the second network stream submap is composed of all remaining nodes except the first network stream submap and edges between the remaining nodes in the to-be-processed network flow graph; An edge between all nodes of the first network stream submap and all nodes of the second network stream submap becomes between the first node and all nodes of the second network stream submap Edge, the first reduced network flow graph includes the first node, the second network stream submap, and between the first node and all nodes of the second network stream submap
  • the minimum cut capacity of the first reduced network flow graph is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
  • the merging unit is specifically configured to remove an edge between the M nodes of the first network stream submap and aggregate the M nodes Is one of the first nodes.
  • the acquiring unit is specifically configured to start from the first endpoint, and the search acquisition includes a third network stream submap of the preset number of nodes, where the third network stream submap includes the preset number of nodes acquired by the search and the preset number of nodes obtained by the search Between the edges, the preset number is greater than or equal to the M; and merging the fourth network stream submaps other than the third network stream submap in the to-be-processed network flow graph into one second a node, the fourth network stream submap is removed from all remaining nodes except the third network stream submap in the to-be-processed network flow graph, and the removing the third network stream submap Composing an edge between all remaining nodes; and forming the second node and the third network stream sub-picture into a fifth network stream sub-picture, all nodes and locations of the fourth network stream sub-picture An edge between all nodes of the third
  • the method further includes:
  • a restoring unit configured to: after the obtaining, the first minimum cut sub-graph of the fifth network stream submap as the first network stream submap according to the minimum cut partition of the fifth network stream submap Restoring the second node to the fourth network stream submap, and the edge between the second node and all nodes of the third network stream submap becomes the fourth network stream submap The edge between all nodes and all nodes of the third network stream submap.
  • the fourth possibility in the second aspect in conjunction with the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect or the third possible implementation of the second aspect, the fourth possibility in the second aspect in the implementation, it also includes:
  • a first recording unit configured by the processing unit to form, by the first node, a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow graph Then, the number of times of reduction of the to-be-processed network flow graph is recorded, and the number of times of reduction of the to-be-processed network flow graph is obtained.
  • the method further includes:
  • a first updating unit configured to update the first reduced network flow graph to the to-be-processed if the number of times of reduction of the to-be-processed network flow graph obtained by the first recording unit is less than a first preset number of times Network flow diagram.
  • the acquiring unit is further configured to obtain a sixth network stream submap from the first reduced network flow graph, where the sixth network stream submap includes K nodes and K nodes. Between the edges, the K is an integer greater than or equal to 2, and the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink a node, when the first endpoint is a sink node, the second endpoint is a source node;
  • the merging unit is further configured to merge the sixth network stream submap obtained by the acquiring unit into a third node;
  • the processing unit is further configured to combine the third node obtained by combining the merging unit with a seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph. Diluting a network flow graph, wherein the seventh network stream submap removes all remaining nodes except the sixth network stream submap from the first reduced network flow graph and the removing the sixth network stream a side between all remaining nodes except the sub-picture; the edge between all the nodes of the sixth network stream sub-picture and all the nodes of the seventh network stream sub-picture becomes the third An edge between the node and all nodes of the seventh network stream submap, the second reduced network flow graph including the seventh network stream submap, the third node, and the third An edge between the node and all nodes of the seventh network stream submap, and a minimum cut capacity of the second reduced network flow graph is equal to a minimum cut capacity of the to-be-processed network flow graph, the first The third node is the second endpoint of the second reduced network flow graph.
  • the method further includes:
  • a second recording unit configured by the processing unit to form the third node and the seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph to form a second reduced network stream
  • the method further includes:
  • a second updating unit configured to update the second reduced network flow graph to the first if the number of times of reduction of the first reduced network flow graph obtained by the second recording unit record is less than a second preset number of times A reduced network flow graph.
  • the network flow graph reduction method and apparatus obtains the first network stream submap from the to-be-processed network flow graph, and then merges the first network stream submap into a first node, and then the first
  • the second network stream sub-picture in the node and the to-be-processed network flow diagram except the first network stream sub-graph constitutes a first reduced network flow graph, and the minimum cut capacity of the first reduced network flow graph is equal to the to-be-processed network flow graph.
  • the minimum cut capacity, the first node is the first end point of the first reduced network flow graph.
  • the first node By merging the first network stream submap of the M nodes including the first endpoint into the first node, the first node becomes the first endpoint of the reduced first reduced network flow graph, which is effective
  • the size of the map is reduced, and the network flow graph to be processed does not need to meet certain rules, so that the scale of the map is reduced.
  • the process has universal applicability.
  • Embodiment 1 is a flowchart of Embodiment 1 of a network flow graph reduction method according to the present invention
  • Embodiment 2 is a flowchart of Embodiment 2 of a network flow graph reduction method according to the present invention
  • FIG. 3 is a schematic diagram of a network flow graph to be processed according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a first sub-picture provided by an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a first sub-picture including a first node according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a first reduced network flow diagram according to an embodiment of the present invention.
  • FIG. 7 is a flowchart of Embodiment 3 of a network flow graph reduction method according to the present invention.
  • Embodiment 8 is a flowchart of Embodiment 4 of a network flow graph reduction method according to the present invention.
  • Embodiment 9 is a flowchart of Embodiment 5 of a network flow graph reduction method according to the present invention.
  • Embodiment 10 is a schematic structural diagram of Embodiment 1 of a network flow graph reduction device according to the present invention.
  • Embodiment 11 is a schematic structural diagram of Embodiment 2 of a network flow graph reduction device according to the present invention.
  • Embodiment 3 of a network flow graph reduction device according to the present invention.
  • FIG. 13 is a schematic structural diagram of Embodiment 4 of a network flow graph reduction device according to the present invention.
  • FIG. 1 is a flowchart of Embodiment 1 of a network flow graph reduction method according to the present invention. As shown in FIG. 1 , the method in this embodiment may include:
  • M is an integer greater than or equal to 2
  • the first endpoint is to be The source node or sink node of the network flow graph.
  • the network flow graph to be processed is a directed graph and a flow graph of the network flow
  • the to-be-processed network flow graph includes edges between N nodes and N nodes, and N nodes are network flows.
  • Each node passing through, the edge between each node represents the network flow relationship between the nodes
  • the N nodes include the source node and the sink node
  • the source node is used to represent the network flow to be processed.
  • the starting node of the network flow of the graph, the sink node is the ending node of the network flow of the network flow graph to be processed, and each side has capacity, and the network flow graph can be used to simulate the traffic volume of the road system and the pipeline.
  • the liquid, the current in the circuit, etc., for example, the side in the network flow diagram can be a water pipe
  • the network flow is the water in the water pipe
  • the capacity of the side is the capacity of the water pipe
  • the source of the water flow serves as the source node
  • the sink of the water flow Point as the sink point
  • the point where any water pipe meets is the node in the network flow graph except the source node and the sink node.
  • the network flows in the network flow graph are all flowing out from the source node, and the network flows in the final network flow will all flow into the sink node, and the edges between the two nodes in the flow direction relationship have a capacity, so
  • the traffic of the network flow flowing on the edge cannot exceed the capacity of the edge, and the maximum traffic of the network flow flowing from the source point is the maximum flow of the to-be-processed network flow graph, and then the minimum cut capacity of the to-be-processed network flow graph The same as the maximum flow of the to-be-processed network flow graph.
  • the embodiment may be configured to include a first network stream submap, where the first network stream submap includes M nodes, where M is an integer greater than or equal to 2, and the M nodes include a first endpoint, and the first endpoint It may be a source node or a sink node of a network flow graph to be processed, where N is an integer greater than or equal to M.
  • the acquired first network stream submap may include a source node of the to-be-processed network flow graph, and the obtained first network stream submap may also include a sink node of the to-be-processed network flow graph.
  • the first network stream submap is merged into a first node, for example, the first network stream submap is reduced to a node.
  • combining the first network stream submap into a first node may include: removing an edge between the M nodes of the first network stream submap; and aggregate the M nodes into a first node.
  • Node specifically, removing the edge between the M nodes of the first network stream sub-picture, it can be considered that the network flow relationship between the M nodes does not exist, and then the M nodes are aggregated into one node. Point, this node is called the first node.
  • the first network and the second network stream sub-picture except the first network stream sub-picture in the to-be-processed network flow graph are formed into a first reduced network flow graph, where a minimum cut capacity of the first reduced network flow graph is equal to The minimum cut capacity of the network flow graph to be processed, the first node is the first of the first reduced network flow graph End point.
  • the network flow graph except the first network stream submap in the to-be-processed network flow graph may be referred to as a second network stream submap, and the second network stream submap is removed from the to-be-processed network flow graph.
  • All remaining nodes except a network stream sub-picture and the edges between all the remaining nodes may be based on all nodes of the first network stream sub-picture and all nodes of the second network stream sub-picture
  • the edge becomes the edge between the first node and all the nodes of the second network stream sub-picture, and the second network stream sub-picture other than the first network stream sub-picture in the to-be-processed network flow picture is merged with the foregoing
  • the first node constitutes a network flow graph
  • the formed network flow graph is referred to as a first reduced network flow graph
  • the obtained first reduced network flow graph includes a first node, a second network stream submap, and the first The edge between the node and all the nodes of the second network stream
  • the minimum cut capacity of the first reduced network flow graph obtained by the above steps in this embodiment is equal to the minimum cut capacity of the network flow graph to be processed, and the first reduced network flow obtained through the above steps.
  • the maximum flow of the graph is equal to the maximum flow of the network flow graph to be processed.
  • the maximum flow minimum cut of the first reduced network flow graph is equivalent to the maximum flow minimum cut of the pending network flow graph.
  • Embodiment 1 of the present invention provides a network flow graph reduction method, which obtains a first network stream submap from a to-be-processed network flow graph, and then merges the first network stream submap into a first node, and then the first node.
  • the second network stream submap except the first network stream submap in the to-be-processed network flow graph constitutes a first reduced network flow graph, and the minimum cut capacity of the first reduced network flow graph is equal to the minimum of the to-be-processed network flow graph
  • the cut capacity, the first node is the first end point of the first reduced network flow graph.
  • the first node By merging the first network stream submap including the M nodes into the first node, the first node becomes the first endpoint of the reduced first reduced network flow graph, which can effectively reduce the scale of the graph. There is no need to process the network flow graph to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
  • Embodiment 2 is a flowchart of Embodiment 2 of a network flow graph reduction method according to the present invention. As shown in FIG. 2, the method in this embodiment may include:
  • the third network stream submap obtained by the search includes an edge between the preset number of nodes obtained by the search and the preset number of nodes obtained by the search.
  • the preset number may be determined according to the actual application scenario, and the embodiment of the present invention is not limited herein. For example, you can start from the sink point and use the Breadth First Search (BFS) method to search the network flow graph to obtain the preset number of nodes including the sink node.
  • BFS Breadth First Search
  • the BFS method is used to search the network flow graph to obtain a third network stream submap of the node of the preset data including the source node. It should be noted that the BFS method and the reverse BFS method are consistent with the prior art, and the embodiments of the present invention are not described herein again.
  • FIG. 3 is a schematic diagram of a network flow graph to be processed according to an embodiment of the present invention.
  • the network flow graph to be processed has numbers 0, 1, 2, 3, 4, 5, 6, and 7.
  • the edge, the number on the side represents the capacity of the network stream on the edge, that is, the maximum flow allowed to flow. If the preset number is 7, then it starts from the junction point (that is, the node numbered 10).
  • the reverse BFS method to search, you can search for the node numbered 7, the node numbered 8, the node numbered 9, the node between the number 7 and the node numbered 10, The edge between the node numbered 8 and the node numbered 10, and the edge between the node numbered 9 and the node numbered 10, and then the reverse BFS is used from the node numbered 7 Method Search, you can search for the node numbered 4, and the edge between the node numbered 7 and the node numbered 5; the reverse B is used from the node numbered 8 The FS method searches to find the node numbered 5, and the edge between the node numbered 8 and the node numbered 5; the node with the number 9 starts the search using the reverse BFS method.
  • the network stream sub-picture includes 7 nodes including the node numbered 10 and the edge between the 7 nodes, respectively, the 7 nodes respectively For nodes numbered 4, 5, 6, 7, 8, 9, and 10.
  • the network flow graph except the third network stream submap in the to-be-processed network flow graph is used as the fourth network stream submap, and the fourth network stream submap is removed from the to-be-processed network flow graph to remove the third network.
  • the remaining nodes other than the stream subgraph and the edges between the remaining nodes except the third network stream subgraph are composed.
  • combining the fourth network stream submap into a second node may include: removing edges between all nodes in the fourth network stream submap; and all nodes of the fourth network stream submap Point aggregation is a first node. Specifically, the edge between all nodes in the fourth network stream submap is removed. It can be considered that the network flow relationship between all nodes in the fourth network stream submap is not It exists, and then all the nodes in the fourth network stream subgraph are aggregated into one node, which is called the second node.
  • the second node and the third network stream sub-picture are combined into a fifth network stream sub-picture.
  • the second node and the third network stream may be formed according to an edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap.
  • the edge between all the nodes of the graph forms a network flow graph with the second node and the third network stream submap described above, and the formed network flow graph is called a fifth network stream submap, and the obtained fifth network is obtained.
  • the stream subgraph includes a second node, a third network stream sub-picture, and an edge between the second node and all nodes of the third network stream sub-picture, and the second node is a fifth network stream sub-picture The second endpoint.
  • the second node when the first endpoint is the source node, that is, starting from the source node, and searching for the third network stream submap including the source node, then the second node may be the fifth network stream submap.
  • a sink node when the first endpoint is a sink node, that is, starting from the sink node, and searching for a third network stream submap including the sink node, the second node may become the fifth network stream A source node of the subgraph.
  • FIG. 4 is a schematic diagram of a first sub-picture according to an embodiment of the present invention.
  • a network stream sub-picture of seven nodes including a junction point numbered 10 Obtaining nodes other than the nodes numbered 4, 5, 6, 7, 8, 9, and 10 in the network flow graph to be processed, that is, nodes numbered 0, 1, 2, and 3, and the number For the edges between the nodes of 0, 1, 2, and 3, remove the edges between the nodes numbered 0, 1, 2, and 3, and aggregate the nodes numbered 0, 1, 2, and 3 into one.
  • Nodes, the nodes obtained by merging can be referred to as nodes numbered s*.
  • the network sub-picture and the second node obtained according to the search form a first sub-picture
  • the first sub-picture includes the nodes 4 and 5, 6, 7, 8, 9, 10 obtained by the search, and the number is s.
  • the node numbered 10 is the first of the first subgraph End point
  • the node numbered s* is the second end point of the first sub-picture
  • the node numbered 10 is the sink point of the first sub-picture.
  • the node numbered s* is the source node of the first submap.
  • the first minimum cut subgraph of the fifth network stream submap is used as the first network stream submap according to the minimum cut partition of the fifth network stream submap.
  • the maximum flow of the fifth network stream submap may be calculated to obtain a maximum flow of the fifth network flow submap, and the maximum flow of the fifth network flow submap is equal to the minimum cut of the fifth network flow submap. Capacity, thereby obtaining a minimum cut set of the fifth network stream sub-picture, the capacity of the minimum cut set being equal to the maximum flow of the first sub-picture, and performing the fifth network flow sub-picture according to the minimum cut set of the first network flow sub-picture
  • the minimum cut is obtained, and the minimum cut of the fifth network stream subgraph is obtained, that is, two mutually disconnected network stream subgraphs obtained by removing the minimum cut set in the fifth network stream subgraph, if a network stream subgraph includes the first The source node of the fifth network stream submap, then the other network stream subgraph includes the sink node of the fifth network stream submap, and at the same time, the two disconnected network stream subgraphs may be referred to as the first minimum cut graph.
  • the minimum cut of the fifth network stream submap includes a second minimum cut subgraph of the first minimum cut subgraph of the fifth network flow submap, and then the fifth network flow submap First minimum cut subgraph as the first network flow FIG.
  • the first minimum cut subgraph comprises M nodes, M comprises a first end-node. Since the first network stream submap is a part of the fifth network stream submap, the preset number may be greater than or equal to M.
  • the maximum flow of the first sub-picture is 15, then the minimum cut capacity of the first sub-picture is 15, and the number is 4 and The capacity of the edge between the nodes numbered 7, the capacity of the edge between the node numbered 5 and the node numbered 8, the edge between the node numbered 9 and the node numbered 10
  • the edge between the point and the node numbered 10 can be collectively referred to as the minimum cut of the first subgraph, then the minimum cut set includes the node numbered 7, the node numbered 8 and the node numbered 10, or
  • the minimum cut set includes a node numbered s*, a node numbered 4, a node numbered 5, a node numbered 6 and a node numbered 9.
  • the first sub-picture can be divided into a first minimum cut sub-picture and a second minimum cut sub-picture, and the first minimum cut sub-picture is a node numbered 7 and numbered 8 , the node numbered 10, And the edge composition between the nodes numbered 7, 8, 10, then the second minimum cut subgraph is a node numbered s*, a node numbered 4, a node numbered 5, numbered The node of 6, the node numbered 9, and the edge between the nodes numbered s*, 4, 5, 6, and 9.
  • FIG. 5 is a schematic diagram of a first sub-picture including a first node according to an embodiment of the present invention.
  • the first minimum cut sub-picture is represented by a number.
  • the node numbered 7 in the first minimum cut graph the node numbered 8 is numbered 10
  • the edge between the nodes is removed, and the node numbered 7, the node numbered 8, and the node numbered 10 are aggregated into a first node, which is the node numbered t*. .
  • the second node may be restored, that is, the second node is restored to a fourth network stream submap other than the third network stream submap in the to-be-processed network flow graph, that is, the second node.
  • the node is restored to all nodes in the fourth network stream submap, and the edges between all the nodes in the fourth network stream submap are restored.
  • the edge between the second node and all the nodes of the third network stream sub-picture becomes the edge between all the nodes of the fourth network stream sub-picture and all the nodes of the third network stream sub-picture.
  • the first network node and the second network stream sub-picture except the first network stream sub-picture in the to-be-processed network flow graph are combined into a first reduced network flow graph.
  • FIG. 6 is a schematic diagram of a first reduced network flow diagram according to an embodiment of the present invention.
  • a node of s* is used.
  • the restoration is performed, that is, the node of s* is restored to the node numbered 0, 1, 2, and 3, and the edge between the nodes numbered 0, 1, 2, and 3.
  • the edges between the components constitute the first reduced network flow graph.
  • the network flow graph reduction method provided by the embodiment of the present invention can reduce the to-be-processed network flow graph shown in FIG.
  • the maximum flow of the to-be-processed network flow graph shown in FIG. 3 is 11, that is, the minimum cut capacity of the to-be-processed network flow graph is 11, and the minimum cut capacity is between the node numbered 0 and number 1.
  • the minimum cut capacity of the first reduced network flow graph is 11, and the minimum cut capacity is also the node numbered 0 and numbered 1.
  • the capacity of the side is equal to the maximum flow minimum cut of the maximum flow minimum cut of the first reduced network flow diagram shown in FIG. 6, and the first reduced network flow diagram shown in FIG. Equivalent to the network flow graph to be processed shown in Figure 3.
  • the network flow graph reduction method provided by the second embodiment of the present invention, by searching from the first endpoint, searches for a third network stream submap including a preset number of nodes, and divides the third network stream in the to-be-processed network flow graph.
  • the fourth network stream sub-picture outside the sub-picture is merged into a second node, and the second node and the third network stream sub-picture are combined into a fifth network stream sub-picture, according to the minimum cut of the fifth network stream sub-picture.
  • the first minimum cut subgraph of the fifth network stream submap is used as the first network stream submap, the first network stream submap is merged into one first node, and the second node is restored to the fourth network stream.
  • the first node and the second network stream sub-picture other than the first network stream sub-picture in the to-be-processed network flow graph form a first reduced network flow graph.
  • the first node becomes the first endpoint of the reduced first reduced network flow graph, which can effectively reduce the scale of the graph.
  • FIG. 7 is a flowchart of Embodiment 3 of a network flow graph reduction method according to the present invention. As shown in FIG. 7 , the method in this embodiment may be based on the network flow graph reduction method embodiment shown in FIG. 1 or FIG. 2 . include:
  • the number of times of reduction of the network flow graph to be processed is recorded, so that the total number of reductions of the network flow graph to be processed can be obtained.
  • the network flow graph to be processed before the network flow graph is to be processed for reduction The number of reductions is recorded as 0.
  • the number of reductions of the network flow graph to be processed is incremented by one, so that the number of reductions of the network flow graph to be processed after the reduction processing can be obtained.
  • S302. Determine whether the number of times of reduction of the to-be-processed network flow graph is less than the first preset number of times. If yes, execute S303. If no, execute S304.
  • determining whether the number of times of reduction of the network flow graph to be processed is less than the first preset number of times, if it is smaller, it indicates that the network flow graph to be processed may be reduced. That is, S303 is executed. If it is not less than, it means that the network flow graph to be processed is not reduced, that is, S304 is executed.
  • the first preset number of times may be the number of iterations set by the user, or may be the default number of iterations of the system. The first preset number of times may be determined according to an actual application scenario, which is not limited herein.
  • the number of times of reduction of the network flow graph to be processed is less than the first preset number of times, it indicates that the network flow graph to be processed may be reduced, and then the first reduced network flow graph is updated to the network flow graph to be processed. That is, S101-S103 is executed again or S201-S207 is executed again.
  • the process ends.
  • the processing network flow graph is reduced from the source node of the to-be-processed network flow graph each time, that is, from the network stream to be processed.
  • the source node of the graph begins to process the network flow graph for a first predetermined number of reductions.
  • the first endpoint is a sink node, that is, each time the processing network flow graph is reduced from the sink point of the to-be-processed network flow graph, that is, the network flow to be processed is
  • the sink point of the graph begins to process the network flow graph for a first predetermined number of reductions.
  • the network flow graph to be processed can be reduced to two nodes, one node is the source node, and the other node is merged by the minimum cut subgraph.
  • the resulting node, the new sink node, then the edge between the source node and the new sink node is the minimum cut set.
  • one node is a sink node, and the other node is a node merged by a minimum cut subgraph, that is, a new source node, then the edge between the new source node and the sink node is the smallest Cut the collection.
  • the network flow graph reduction method provided by the third embodiment of the present invention is further processed by The number of times of reduction of the network flow graph is recorded, and the number of times of the network flow graph to be processed is reduced. If the number of times of the network flow graph to be processed is less than the first preset number, the first reduced network flow graph is updated to the network flow graph to be processed. , then reduce the processing. This can effectively and greatly reduce the scale of the graph, and does not require the network flow graph to be processed to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
  • FIG. 8 is a flowchart of Embodiment 4 of a network flow graph reduction method according to the present invention. As shown in FIG. 8 , the method in this embodiment is based on any embodiment of the network flow graph reduction method shown in FIG. 1 to FIG. 3 . It can also include:
  • the sixth network stream submap includes an edge between the K nodes and the K nodes, and K is an integer greater than or equal to 2.
  • K is an integer greater than or equal to 2.
  • the third node and the seventh network stream submap except the sixth network stream submap in the first reduced network flow graph form a second reduced network flow graph.
  • the seventh network stream submap is removed from all remaining nodes except the sixth network stream submap in the first reduced network flow graph and all remaining nodes except the sixth network stream submap Edge composition; the edge between all nodes of the sixth network stream subgraph and all nodes of the seventh network stream subgraph becomes the edge between all nodes of the third node and the seventh network stream subgraph,
  • the second reduced network flow graph includes a seventh network stream submap, a third node, and an edge between all nodes of the third node and the seventh network stream submap, and the second reduced network flow graph is minimally cut.
  • the capacity is equal to the minimum cut capacity of the network flow graph to be processed, and the third node is the second end point of the second reduced network flow graph.
  • the specific implementation process of S401-S403 in the embodiment of the present invention is similar to the specific implementation process of S101-S103 in the first embodiment of the present invention, or the specific implementation process of S401-S403 in the embodiment of the present invention and the method of the present invention
  • the specific implementation process of the S201-S207 in the second embodiment is similar.
  • the network flow graph to be processed is subjected to a reduction process to obtain a first reduced network flow graph; and then the sink is reduced from the first network flow graph.
  • the first reduced network flow graph is subjected to a reduction process to obtain a second reduced network flow graph; and then the second reduced network flow graph is updated to the pending network flow graph, from the updated pending network flow graph.
  • the source node starts, and the updated network flow graph to be processed Performing a reduction process to obtain a first reduced network flow graph; then, starting from the sink point of the first reduced network flow graph, performing a reduction process on the first reduced network flow graph to obtain a second reduced network flow graph; In this way, the reduction process is performed from the source node at a time, and the reduction process is started from the sink node at a time.
  • the network flow graph to be processed is subjected to a reduction process to obtain a first reduced network flow graph; and then starting from the source node of the first reduced network flow graph, the first The network flow graph is reduced to perform a reduction process to obtain a second reduced network flow graph; then the second reduced network flow graph is updated to be a pending network flow graph, starting from the sink point of the updated pending network flow graph, and updating
  • the to-be-processed network flow graph is subjected to a reduction process to obtain a first reduced network flow graph; and then, starting from the source node of the first reduced network flow graph, the first reduced network flow graph is subjected to a reduction process to obtain the first Second, the network flow graph is reduced; and so on, the reduction processing is started from the sink node once, and the reduction processing is performed from the source node at a time.
  • the network flow graph to be processed can be reduced to two nodes, and one node is a node formed by merging the smallest cut sub-pictures, that is, a new source node and another node. It is also the node that is merged by the smallest cut subgraph, that is, the new sink point, then the edge between the new source node and the new sink point is the minimum cut.
  • the network flow graph to be processed may be reduced from the source node of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, The description may stop reducing the processing of the network flow graph from the source node, and then reduce the first reduced network flow graph from the sink point of the first reduced network flow graph obtained by the reduction processing.
  • the network flow graph to be processed may be reduced from the sink point of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, the slave node may no longer be removed from the sink node.
  • the processing of the network flow graph is started to be reduced, and then the first reduced network flow graph is reduced from the source node of the first reduced network flow graph obtained by the reduction processing.
  • the network flow graph reduction method provided by Embodiment 4 of the present invention further includes: obtaining a sixth network stream submap from the first reduced network flow graph; and merging the sixth network stream submap into a third node;
  • the third node and the seventh network stream submap except the sixth network stream submap in the first reduced network flow graph form a second reduced network flow graph, and the minimum cut capacity of the second reduced network flow graph is equal to the network to be processed.
  • the minimum cut capacity of the flow graph, and the third node is the second end point of the second reduced network flow graph.
  • the third node becomes the second endpoint of the reduced second reduced network flow graph, which can effectively reduce the scale of the graph.
  • the network flow graph to be processed needs to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
  • FIG. 9 is a flowchart of Embodiment 5 of a network flow graph reduction method according to the present invention. As shown in FIG. 9 , the method in this embodiment may further include:
  • each time the first reduced network flow graph is reduced the number of times of reduction of the first reduced network flow graph is recorded, so that the total number of reductions of the first reduced network flow graph can be obtained.
  • the number of reductions of the first reduced network flow graph is recorded as 0, and when the first reduced network flow graph is reduced, the first reduced network flow graph is obtained.
  • the number of reductions is incremented by one, so that the number of reductions of the first reduced network flow graph after this reduction process can be obtained.
  • the reduction processing is performed, that is, S503 is executed. If it is not smaller, it means that the first reduced network flow graph can no longer be reduced, that is, S504 is executed.
  • the second preset number of times may be the number of iterations set by the user, and may be the default number of iterations of the system. The second preset number of times may be determined according to an actual application scenario, which is not limited herein.
  • the number of times of reduction of the first reduced network flow graph is less than the second preset number of times, it may be further that the first reduced network flow graph may be reduced, and then the second reduced network flow graph is updated to the first reduced The network flow graph, that is, S401-S403 is executed again.
  • the process ends.
  • the network flow graph to be processed may be reduced from the source node of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, The description can no longer reduce the processing of the network flow graph from the source node. Then, starting from the sink point of the first reduced network flow graph obtained by the reduction process, the first reduced network flow graph is reduced, and when the number of reductions of the first reduced network flow graph is not less than the second preset number, The processing of the network flow graph is no longer reduced from the sink node, that is, the reduction processing is completed, and the flow is ended.
  • the network flow graph to be processed may be reduced from the sink point of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, the description may no longer be from the sink node.
  • start to process the network flow graph for reduction processing and then reduce the first reduced network flow graph from the source node of the first reduced network flow graph obtained by the reduction processing, when the first reduced network flow graph is reduced by a small number of times If the second preset number is less than the second preset number, it may be that the network flow graph to be processed is not reduced from the source node, that is, the reduction processing is completed, and the flow is ended.
  • the network flow graph to be processed can be reduced to two nodes, and the two nodes are respectively nodes merged by different minimum cut sub-graphs, that is, new source nodes and The new sink point, then the edge between the new source node and the new sink node is the minimum cut set.
  • the network flow graph to be processed may be reduced from the source node of the network flow graph to be processed, and then the sink point of the first reduced network flow graph obtained by the reduction processing is started.
  • the reduction of the first reduced network flow graph is performed.
  • the network flow graph to be processed may be reduced from the sink point of the network flow graph to be processed, and then the first reduced network flow graph is started from the source node of the first reduced network flow graph obtained by the reduction processing.
  • the reduction processing when the number of reductions of the first reduced network flow graph is not less than the second preset number of times, indicates that the network flow graph to be processed may not be reduced from the source node, that is, the reduction processing is completed, and the flow is ended.
  • the network flow graph reduction method provided by the fifth embodiment of the present invention further obtains the reduced number of times of the first reduced network flow graph by recording the reduced number of times of the first reduced network flow graph; when the first reduced network flow graph is reduced When the number of times is less than the second preset number of times, the second reduced network flow graph is updated to the first reduced network flow graph, and then the reduction processing is performed.
  • This can effectively and greatly reduce the scale of the graph, and does not require the network flow graph to be processed to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
  • FIG. 10 is a schematic structural diagram of Embodiment 1 of a network flow graph reduction apparatus according to the present invention.
  • the apparatus in this embodiment may include: an obtaining unit 11, a merging unit 12, and a processing unit 13,
  • the obtaining unit 11 is configured to obtain a first network stream submap from the to-be-processed network flow graph, where the first network stream submap includes edges between the M nodes and the M nodes, and the M nodes
  • the point includes a first endpoint, the M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes an edge between the N nodes and the N nodes, where the N nodes include a source a node and a sink node, where N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is a network flow used to represent the to-be-processed network flow graph
  • the starting node, the sink node is an end node of the network flow, wherein an
  • the second network stream submap being divided by the to-be-processed network flow graph All remaining nodes outside the first network stream sub-picture and edges between the remaining nodes; all nodes of the first network stream sub-picture and the second network stream sub-picture An edge between all nodes becomes an edge between the first node and all nodes of the second network stream submap, the first reduced network flow graph including the first node, the a second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum cut capacity of the first reduced network flow graph is equal to the to-be-processed The minimum cut capacity of the network flow graph, the first node being the first endpoint of the first reduced network flow graph.
  • the device in this embodiment may be used to perform the technical solution of the foregoing method embodiment of the present invention.
  • the implementation principle and the technical effect are similar.
  • FIG. 11 is a schematic structural diagram of Embodiment 2 of a network flow graph reduction device according to the present invention.
  • the device in this embodiment is based on the device structure shown in FIG. 10 , and optionally, the merging unit 12 is specifically configured to An edge between the M nodes of the first network stream submap is removed, and the M nodes are aggregated into one of the first nodes.
  • the obtaining unit 11 is specifically configured to: start from the first endpoint, search for a third network stream submap including a preset number of nodes, where the third network stream submap includes the search An edge between the preset number of nodes and the preset number of nodes obtained by the search, the preset number is greater than or equal to the M; and the network flow graph to be processed is divided
  • the fourth network stream submap outside the third network stream submap is merged into a second node, and the fourth network stream submap is removed from the to-be-processed network flow graph by the third network stream All remaining nodes outside the graph and Determining an edge composition between all remaining nodes except the third network stream submap; and forming the second node and the third network stream submap into a fifth network stream submap, An edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap becomes between the second node and all nodes of the third network stream submap
  • the fifth network stream submap includes the second node, the third network stream submap
  • the apparatus in this embodiment may further include: a restoring unit 14 configured to obtain, according to a minimum cut partition of the fifth network stream submap, the fifth network stream submap. After the minimum cut subgraph is used as the first network stream submap, the second node is restored to the fourth network stream submap, and the second node and the third network stream submap are The edge between all nodes becomes the edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap.
  • a restoring unit 14 configured to obtain, according to a minimum cut partition of the fifth network stream submap, the fifth network stream submap. After the minimum cut subgraph is used as the first network stream submap, the second node is restored to the fourth network stream submap, and the second node and the third network stream submap are The edge between all nodes becomes the edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap.
  • the apparatus in this embodiment may further include: a first recording unit 15 configured by the processing unit 13 to divide the first node and the to-be-processed network flow diagram except the first network After the second network stream submap other than the stream submap constitutes the first reduced network flow graph, the number of times of the to-be-processed network flow graph is reduced, and the number of times of the to-be-processed network flow graph is obtained.
  • a first recording unit 15 configured by the processing unit 13 to divide the first node and the to-be-processed network flow diagram except the first network After the second network stream submap other than the stream submap constitutes the first reduced network flow graph, the number of times of the to-be-processed network flow graph is reduced, and the number of times of the to-be-processed network flow graph is obtained.
  • the apparatus of this embodiment may further include: a first updating unit 16, where the first update unit 16 is configured to reduce the number of times of the to-be-processed network flow graph obtained by the first recording unit 15 to be less than the first pre- And setting the number of times, updating the first reduced network flow graph to the to-be-processed network flow graph.
  • a first updating unit 16 where the first update unit 16 is configured to reduce the number of times of the to-be-processed network flow graph obtained by the first recording unit 15 to be less than the first pre- And setting the number of times, updating the first reduced network flow graph to the to-be-processed network flow graph.
  • the device in this embodiment may be used to perform the technical solution of the foregoing method embodiment of the present invention.
  • the implementation principle and the technical effect are similar.
  • FIG. 12 is a schematic structural diagram of Embodiment 3 of a network flow graph reduction apparatus according to the present invention. As shown in FIG. 12, the apparatus of this embodiment is based on the apparatus structure shown in FIG. 11, and further, if the first recording unit 15 records and obtains The obtaining unit 11 is further configured to obtain the sixth network stream submap from the first reduced network flow graph, where the number of times of the to-be-processed network flow graph is not smaller than the first preset number of times.
  • the sixth network stream submap includes edges between K nodes and K nodes, the K is an integer greater than or equal to 2, and the K nodes include a second endpoint, where When the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node; the merging unit 12 is further used Combining the sixth network stream sub-graph obtained by the obtaining unit 11 into a third node; the processing unit 13 is further configured to merge the third node obtained by the merging unit 12 with the first reduction
  • the seventh network stream submap in addition to the sixth network stream submap in the network flow graph constitutes a second reduced network flow graph, wherein the seventh network stream submap is removed from the first reduced network flow graph All remaining nodes other than the six network stream sub-pictures and the edges between the remaining nodes except the sixth network stream sub-picture are deleted; all nodes of the sixth network stream sub-picture are An edge between all nodes of the seventh network stream submap becomes all
  • the apparatus of this embodiment may further include: a second recording unit 17, configured by the processing unit 13 to divide the third node from the first reduced network flow graph After the seventh network stream submap other than the six network stream submaps constitutes the second reduced network flow graph, the number of reductions of the first reduced network flow graph is recorded, and the number of reductions of the first reduced network flow graph is obtained. .
  • the apparatus of this embodiment may further include: a second update unit 18, where the second update unit 18 is configured to reduce the number of times of the first reduced network flow graph obtained by the second recording unit 17 to be smaller than And a second preset number of times, updating the second reduced network flow graph to the first reduced network flow graph.
  • the device in this embodiment may be used to perform the technical solution of the foregoing method embodiment of the present invention.
  • the implementation principle and the technical effect are similar.
  • FIG. 13 is a schematic structural diagram of Embodiment 4 of a network flow graph reduction apparatus according to the present invention.
  • the apparatus of this embodiment includes a memory 21 and a processor 22 connected to the memory 21, wherein the memory 21 stores a set of programs.
  • the code 21 may include a non-volatile memory.
  • the processor 22 can be a central processor (Central) A processing unit (CPU), or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
  • the processor 22 is configured to call the program code stored in the memory 21 for performing the following operations:
  • the M is an integer greater than or equal to 2
  • the to-be-processed network flow graph includes an edge between the N nodes and the N nodes, where the N nodes include a source node and a sink node.
  • the N is an integer greater than M
  • the first endpoint is a source node or a sink node
  • the source node is a starting node of a network flow used to represent the to-be-processed network flow graph.
  • the summary node is an end node of the network flow, wherein an edge between each node represents a network flow relationship between the nodes;
  • the second network proxy submap is Determining, in the processing network flow graph, all remaining nodes except the first network stream submap and edge components between the remaining nodes; all nodes and locations of the first network stream submap
  • An edge between all nodes of the second network stream submap becomes an edge between the first node and all nodes of the second network stream submap
  • the first reduced network flow graph includes a first node, the second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum of the first reduced network flow graph
  • the cut capacity is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
  • the merging the first part of the to-be-processed network flow graph into a first node comprises: removing an edge between the M nodes of the first network stream submap; The nodes are aggregated into one of the first nodes.
  • the obtaining the first network stream submap from the to-be-processed network flow graph includes:
  • the third network stream submap including a preset number of nodes, where the third network stream submap includes the preset number of nodes and locations obtained by the search
  • the search for the edge between the preset number of nodes, the preset number is greater than or equal to the M;
  • a fifth network stream submap Forming, by the second node and the third network stream submap, a fifth network stream submap, where all nodes of the fourth network stream submap and all nodes of the third network stream submap An edge between the second node and all nodes of the third network stream submap, the fifth network stream submap including the second node, the third network a stream submap and an edge between the second node and all nodes of the third network stream submap, the second node being a second endpoint of the fifth network stream submap;
  • the second endpoint when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node;
  • the method further includes:
  • the method further includes: Recording the reduced number of times of the to-be-processed network flow graph to obtain a reduced number of times of the to-be-processed network flow graph.
  • the number of times of reduction of the to-be-processed network flow graph is less than the first preset number of times, updating the first reduced network flow graph to the to-be-processed network flow graph.
  • the method further includes:
  • the sixth network stream submap includes edges between K nodes and K nodes, where K is greater than or equal to 2 An integer, wherein the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node The second endpoint is a source node;
  • a seventh network stream sub-picture other than the sixth network stream sub-picture in the first reduced network flow graph to form a second reduced network flow graph, where the seventh network flow sub-graph is configured by The first Reducing, in the network flow graph, all remaining nodes except the sixth network stream submap and edge components between the remaining nodes except the sixth network stream submap; An edge between all nodes of the network stream submap and all nodes of the seventh network stream submap becomes an edge between the third node and all nodes of the seventh network stream submap
  • the second reduced network flow graph includes the seventh network stream submap, the third node, and an edge between the third node and all nodes of the seventh network stream submap
  • the minimum cut capacity of the second reduced network flow graph is equal to the minimum cut capacity of the first reduced network flow graph, and the third node is the second endpoint of the second reduced network flow graph.
  • the method further includes : recording the reduced number of times of the first reduced network flow graph to obtain a reduced number of times of the first reduced network flow graph.
  • the number of times of reduction of the first reduced network flow graph is less than a second preset number of times, updating the second reduced network flow graph to the first reduced network flow graph.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Abstract

Embodiments of the present invention provide a method and an apparatus for reducing a network flow graph. The method comprises: obtaining first network flow subgraphs from a to-be-processed network flow graph, the first network flow subgraphs comprising M nodes and edges between the M nodes, and the M nodes comprising a first endpoint; combining the first network flow subgraphs into a first node; and forming a first reduction network flow graph by the first node and second network flow subgraphs except the first network flow subgraphs in the to-be-processed network flow graph, a capacity (a maximum flow value) of a minimum cut of the first reduction network flow graph being equal to a capacity (a maximum flow value) of a minimum cut of the to-be-processed network flow graph, and the first node being a first endpoint of the first reduction network flow graph, so that a scale of a graph can be effectively reduced. According to the embodiments of the present invention, a to-be-processed network flow graph does not need to conform to a certain rule, so that a process of reducing a scale of a graph has universal applicability.

Description

网络流图缩减方法和装置Network flow graph reduction method and device
本申请要求于2013年09月29日提交中国专利局、申请号为201310456975.0、发明名称为“网络流图缩减方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201310456975.0, entitled "Network Flow Map Reduction Method and Apparatus", filed on Sep. 29, 2013, the entire disclosure of which is incorporated herein by reference. .
技术领域Technical field
本发明实施例涉及算法的图论和组合优化领域,尤其涉及一种网络流图缩减方法和装置。The embodiments of the present invention relate to the field of graph theory and combination optimization of algorithms, and in particular, to a network stream graph reduction method and apparatus.
背景技术Background technique
最大流最小割问题是图论和组合优化中经典问题,例如社交网络的局部社区发现、Sybil攻击防御系统、网上内容投票系统、Google的广告系统、垃圾网站的发现、计算机视觉领域、VLSI布局设计、飞机航班安排、DNA多序列对比等这些应用都可以建模成最大流最小割算法来解决。最大流是在一个有向图中各结点之间的每个边的最大流量,其中,源结点流出的最大流量是该有向图的最大流,汇结点流入的最大流量是该有向图的最大流,其余结点的流入量等于流出量,各结点之间的每条边的流量不能超过容量限制。在该有向图中,去掉一些边,使得有向图变为两个不连通的子图,并且源点和汇点分别在不同的子图中,每个子图可以称为一个割,去掉的这些边的流量之和就是割的容量,最小割就是所有割中容量最小的割,最大流值等于最小割的容量。当有向图规模很大时,采用最大流最小割算法来求最大流最小割的运行时间很长。The maximum flow minimum cut problem is a classic problem in graph theory and combinatorial optimization, such as local community discovery of social networks, Sybil attack defense system, online content voting system, Google's advertising system, spam discovery, computer vision, VLSI layout design. Applications such as aircraft flight schedules and DNA multi-sequence comparisons can be modeled as maximum flow minimum cut algorithms. The maximum flow is the maximum flow of each edge between the nodes in a directed graph, wherein the maximum flow from the source node is the maximum flow of the directed graph, and the maximum flow into the junction is the For the maximum flow to the graph, the inflow of the remaining nodes is equal to the outflow, and the flow rate of each edge between the nodes cannot exceed the capacity limit. In the directed graph, some edges are removed, so that the directed graph becomes two unconnected subgraphs, and the source point and the sink point are respectively in different subgraphs, and each subgraph can be called a cut, removed. The sum of the flows of these edges is the cut capacity, the minimum cut is the cut with the smallest cut capacity, and the maximum flow value is equal to the minimum cut capacity. When the size of the directed graph is large, the maximum flow minimum cut algorithm is used to find the maximum flow minimum cut time is very long.
现有技术中,可以通过减少有向图中的结点和边的数量,来缩减有向图的规模,也就是基于结点模式匹配的方法来缩减有向图的规模,即观察有向图的结构,若一些结点的模式符合预设的模式时,则可以将该些结点合并为一个结点,从而达到缩减有向图规模的目的。In the prior art, the scale of the directed graph can be reduced by reducing the number of nodes and edges in the directed graph, that is, the method based on the node pattern matching is used to reduce the scale of the directed graph, that is, to observe the directed graph. The structure, if some of the nodes' patterns conform to the preset mode, the nodes can be combined into one node, thereby reducing the scale of the directed graph.
但是,基于结点模式匹配的方法只适用于计算机视觉和理论物理领域,只能处理具有特殊结构的规则图,无法处理非规则的有向图,适用性较差。 However, the method based on node pattern matching is only applicable to the fields of computer vision and theoretical physics. It can only process rule diagrams with special structure, cannot handle irregular directed graphs, and has poor applicability.
发明内容Summary of the invention
本发明实施例提供一种网络流图缩减方法和装置,用于有效地缩减图规模,不需要待处理网络流图符合一定的规则,使得对图规模进行缩减的过程具有普遍的适用性。The embodiment of the invention provides a network flow graph reduction method and device, which is used for effectively reducing the scale of the graph, and does not require the network flow graph to be processed to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
第一方面,本发明实施例提供一种网络流图缩减方法,包括:从待处理网络流图中获取第一网络流子图,所述第一网络流子图包括M个结点和M个结点之间的边,所述M个结点中包括第一端点,所述M为大于或等于2的整数,所述待处理网络流图包括N个结点和N个结点之间的边,所述N个结点中包括源结点和汇结点,所述N为大于M的整数,所述第一端点为源结点或者汇结点,所述源结点为用以表示所述待处理网络流图的网络流的起始结点,所述汇结点为所述网络流的结束结点,其中,各个结点之间的边表示各个结点之间的网络流关系;In a first aspect, an embodiment of the present invention provides a network flow graph reduction method, including: acquiring a first network stream submap from a to-be-processed network flow graph, where the first network stream submap includes M nodes and M An edge between nodes, wherein the M nodes include a first endpoint, the M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes N nodes and N nodes The N nodes include a source node and a sink node, the N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is used a starting node of the network flow indicating the network flow graph to be processed, the sink point being an end node of the network flow, wherein an edge between each node represents a network between each node Flow relationship
将所述第一网络流子图合并成一个第一结点;Combining the first network stream submap into a first node;
将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,所述第二网络流子图由所述待处理网络流图中除去所述第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;所述第一网络流子图的所有结点与所述第二网络流子图的所有结点之间的边成为所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图包括所述第一结点、所述第二网络流子图,以及所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第一结点为所述第一缩减网络流图的第一端点。Forming, by the first node, a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow graph, where the second network proxy submap is Determining, in the processing network flow graph, all remaining nodes except the first network stream submap and edge components between the remaining nodes; all nodes and locations of the first network stream submap An edge between all nodes of the second network stream submap becomes an edge between the first node and all nodes of the second network stream submap, and the first reduced network flow graph includes a first node, the second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum of the first reduced network flow graph The cut capacity is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
在第一方面的第一种可能的实现方式中,所述将所述第一部分待处理网络流图合并成一个第一结点,包括:In a first possible implementation manner of the first aspect, the combining the first part of the to-be-processed network flow diagram into a first node includes:
将所述第一网络流子图的M个结点之间的边去掉;Removing the edge between the M nodes of the first network stream submap;
将所述M个结点聚合为一个所述第一结点。The M nodes are aggregated into one of the first nodes.
结合第一方面或第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述从待处理网络流图中获取第一网络流子图,包括:With reference to the first aspect, or the first possible implementation manner of the first aspect, in the second possible implementation manner of the first aspect, the obtaining, by the network flow graph to be processed, the first network flow sub-map includes:
从所述第一端点开始,搜索获取包括预设个数结点的第三网络流子图, 所述第三网络流子图包括所述搜索获取的所述预设个数结点和所述搜索获取的所述预设个数结点之间的边,所述预设个数大于或等于所述M;Starting from the first endpoint, searching for a third network stream submap including a preset number of nodes, The third network stream submap includes an edge between the preset number of nodes acquired by the search and the preset number of nodes acquired by the search, where the preset number is greater than or equal to The M;
将所述待处理网络流图中除所述第三网络流子图之外的第四网络流子图合并为一个第二结点,所述第四网络流子图由所述待处理网络流图中除去所述第三网络流子图之外的所有剩余结点以及所述除去所述第三网络流子图之外的所有剩余结点之间的边组成;Merging the fourth network stream submap other than the third network stream submap in the to-be-processed network flow graph into a second node, where the fourth network stream submap is used by the to-be-processed network stream Removing all remaining nodes except the third network stream submap and edge components between the remaining nodes except the third network stream submap;
将所述第二结点与所述第三网络流子图组成第五网络流子图,所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,所述第五网络流子图包括所述第二结点、所述第三网络流子图以及所述第二结点与所述第三网络流子图的所有结点之间的边,所述第二结点为所述第五网络流子图的第二端点;Forming, by the second node and the third network stream submap, a fifth network stream submap, where all nodes of the fourth network stream submap and all nodes of the third network stream submap An edge between the second node and all nodes of the third network stream submap, the fifth network stream submap including the second node, the third network a stream submap and an edge between the second node and all nodes of the third network stream submap, the second node being a second endpoint of the fifth network stream submap;
其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;Wherein, when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node;
根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图。And determining, according to the minimum cut partition of the fifth network stream submap, the first minimum cut subgraph of the fifth network stream submap as the first network stream submap.
结合第一方面的第二种可能的实现方式,在第一方面的第三种可能的实现方式中,所述根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图之后,还包括:With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner of the foregoing aspect, the fifth network flow according to the minimum cut partition of the fifth network stream submap After the first minimum cut subgraph of the subgraph is used as the first network stream submap, the method further includes:
将所述第二结点还原为所述第四网络流子图,所述第二结点与所述第三网络流子图的所有结点之间的边成为所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边。Restoring the second node to the fourth network stream submap, and the edge between the second node and all nodes of the third network stream submap becomes the fourth network stream submap The edge between all nodes and all nodes of the third network stream submap.
结合第一方面或第一方面的第一种可能的实现方式或第一方面的第二种可能的实现方式或第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,所述将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图之后,还包括:In conjunction with the first aspect or the first possible implementation of the first aspect or the second possible implementation of the first aspect or the third possible implementation of the first aspect, the fourth possibility in the first aspect In the implementation manner, after the first node and the second network stream submap other than the first network stream submap in the to-be-processed network flow graph form a first reduced network flow graph, the method further includes :
将所述待处理网络流图的缩减次数进行记录,获得所述待处理网络流图的缩减次数。Recording the reduced number of times of the to-be-processed network flow graph to obtain a reduced number of times of the to-be-processed network flow graph.
结合第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,若所述待处理网络流图的缩减次数小于第一预设次数,则将 所述第一缩减网络流图更新为所述待处理网络流图。With the fourth possible implementation of the first aspect, in a fifth possible implementation manner of the first aspect, if the number of times of the network flow graph to be processed is smaller than the first preset number of times, The first reduced network flow graph is updated to the to-be-processed network flow graph.
结合第一方面的第五种可能的实现方式,在第一方面的第六种可能的实现方式中,若所述待处理网络流图的缩减次数不小于所述第一预设次数,则所述方法还包括:With the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, if the number of times of the to-be-processed network flow graph is not smaller than the first preset number of times, The method also includes:
从所述第一缩减网络流图中获取第六网络流子图,所述第六网络流子图包括K个结点和K个结点之间的边,所述K为大于或等于2的整数,所述K个结点中包括第二端点,其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;Obtaining a sixth network stream submap from the first reduced network flow graph, where the sixth network stream submap includes edges between K nodes and K nodes, where K is greater than or equal to 2 An integer, wherein the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node The second endpoint is a source node;
将所述第六网络流子图合并成一个第三结点;Combining the sixth network stream submap into a third node;
将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,所述第七网络流子图由所述第一缩减网络流图中除去所述第六网络流子图之外的所有剩余结点以及所述除去所述第六网络流子图之外的所有剩余结点之间的边组成;所述第六网络流子图的所有结点与所述第七网络流子图的所有结点之间的边,成为所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图包括所述第七网络流子图、所述第三结点、以及所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图的最小割的容量等于所述第一缩减网络流图的最小割的容量,所述第三结点为所述第二缩减网络流图的第二端点。Forming, by the third node, a seventh network stream sub-picture other than the sixth network stream sub-picture in the first reduced network flow graph to form a second reduced network flow graph, where the seventh network flow sub-graph is configured by Removing, in the first reduced network flow diagram, all remaining nodes except the sixth network stream submap and edge components between the remaining nodes except the sixth network stream submap; An edge between all nodes of the sixth network stream submap and all nodes of the seventh network stream submap becomes all nodes of the third node and the seventh network stream submap The second reduced network flow graph includes the seventh network stream submap, the third node, and all nodes of the third node and the seventh network stream submap Between the edges, the minimum cut capacity of the second reduced network flow graph is equal to the minimum cut capacity of the first reduced network flow graph, and the third node is the second reduced network flow graph Two endpoints.
结合第一方面的第六种可能的实现方式,在第一方面的第七种可能的实现方式中,所述将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图之后,还包括:With reference to the sixth possible implementation manner of the first aspect, in a seventh possible implementation manner of the first aspect, the third node and the first reduced network flow graph except the sixth network After the seventh network stream submap outside the stream submap constitutes the second reduced network flow graph, the method further includes:
将所述第一缩减网络流图的缩减次数进行记录,获得所述第一缩减网络流图的缩减次数。Recording the number of reductions of the first reduced network flow graph to obtain a reduced number of times of the first reduced network flow graph.
结合第一方面的第七种可能的实现方式,在第一方面的第八种可能的实现方式中,若所述第一缩减网络流图的缩减次数小于第二预设次数,则将所述第二缩减网络流图更新为所述第一缩减网络流图。In conjunction with the seventh possible implementation of the first aspect, in an eighth possible implementation manner of the first aspect, if the reduced number of times of the first reduced network flow graph is less than a second preset number of times, The second reduced network flow graph is updated to the first reduced network flow graph.
第二方面,本发明实施例提供一种网络流图缩减装置,包括:In a second aspect, an embodiment of the present invention provides a network flow graph reduction device, including:
获取单元,用于从待处理网络流图中获取第一网络流子图,所述第一网络流子图包括M个结点和M个结点之间的边,所述M个结点中包括第一端点,所述M为大于或等于2的整数,所述待处理网络流图包括N个结 点和N个结点之间的边,所述N个结点中包括源结点和汇结点,所述N为大于M的整数,所述第一端点为源结点或者汇结点,所述源结点为用以表示所述待处理网络流图的网络流的起始结点,所述汇结点为所述网络流的结束结点,其中,各个结点之间的边表示各个结点之间的网络流关系;An acquiring unit, configured to obtain a first network stream sub-picture from a to-be-processed network flow graph, where the first network stream sub-picture includes an edge between the M nodes and the M nodes, where the M nodes are Including a first endpoint, the M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes N junctions An edge between the point and the N nodes, wherein the N nodes include a source node and a sink node, the N is an integer greater than M, and the first endpoint is a source node or a sink node The source node is a starting node of the network flow for indicating the network flow graph to be processed, and the sink node is an ending node of the network flow, wherein an edge between each node Indicates the network flow relationship between nodes;
合并单元,用于将所述获取单元获取的第一网络流子图合并成一个第一结点;a merging unit, configured to merge the first network stream sub-graph obtained by the acquiring unit into a first node;
处理单元,用于将所述合并单元合并获得的所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,所述第二网络流子图由所述待处理网络流图中除去所述第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;所述第一网络流子图的所有结点与所述第二网络流子图的所有结点之间的边成为所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图包括所述第一结点、所述第二网络流子图,以及所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第一结点为所述第一缩减网络流图的第一端点。a processing unit, configured to combine the first node obtained by combining the merging unit with a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow The second network stream submap is composed of all remaining nodes except the first network stream submap and edges between the remaining nodes in the to-be-processed network flow graph; An edge between all nodes of the first network stream submap and all nodes of the second network stream submap becomes between the first node and all nodes of the second network stream submap Edge, the first reduced network flow graph includes the first node, the second network stream submap, and between the first node and all nodes of the second network stream submap The minimum cut capacity of the first reduced network flow graph is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
在第二方面的第一种可能的实现方式中,所述合并单元具体用于将所述第一网络流子图的M个结点之间的边去掉,并将所述M个结点聚合为一个所述第一结点。In a first possible implementation manner of the second aspect, the merging unit is specifically configured to remove an edge between the M nodes of the first network stream submap and aggregate the M nodes Is one of the first nodes.
结合第二方面或第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述获取单元具体用于从所述第一端点开始,搜索获取包括预设个数结点的第三网络流子图,所述第三网络流子图包括所述搜索获取的所述预设个数结点和所述搜索获取的所述预设个数结点之间的边,所述预设个数大于或等于所述M;将所述待处理网络流图中除所述第三网络流子图之外的第四网络流子图合并为一个第二结点,所述第四网络流子图由所述待处理网络流图中除去所述第三网络流子图之外的所有剩余结点以及所述除去所述第三网络流子图之外的所有剩余结点之间的边组成;并将所述第二结点与所述第三网络流子图组成第五网络流子图,所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,所述第五网络流子图包括所述第二结点、所述第三网络流子图以及所述第二结点与 所述第三网络流子图的所有结点之间的边,所述第二结点为所述第五网络流子图的第二端点;其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图。With reference to the second aspect or the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the acquiring unit is specifically configured to start from the first endpoint, and the search acquisition includes a third network stream submap of the preset number of nodes, where the third network stream submap includes the preset number of nodes acquired by the search and the preset number of nodes obtained by the search Between the edges, the preset number is greater than or equal to the M; and merging the fourth network stream submaps other than the third network stream submap in the to-be-processed network flow graph into one second a node, the fourth network stream submap is removed from all remaining nodes except the third network stream submap in the to-be-processed network flow graph, and the removing the third network stream submap Composing an edge between all remaining nodes; and forming the second node and the third network stream sub-picture into a fifth network stream sub-picture, all nodes and locations of the fourth network stream sub-picture An edge between all nodes of the third network stream submap becomes the second node and the third network stream An edge between all nodes of the subgraph, the fifth network stream submap including the second node, the third network stream submap, and the second node and An edge between all nodes of the third network stream submap, the second node being a second endpoint of the fifth network stream submap; wherein, when the first endpoint is a source node The second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node; according to the minimum cut of the fifth network stream submap, The first minimum cut subgraph of the fifth network stream submap is used as the first network stream submap.
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,还包括:In conjunction with the second possible implementation of the second aspect, in a third possible implementation of the second aspect, the method further includes:
还原单元,用于所述获取单元根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图之后,将所述第二结点还原为所述第四网络流子图,所述第二结点与所述第三网络流子图的所有结点之间的边成为所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边。a restoring unit, configured to: after the obtaining, the first minimum cut sub-graph of the fifth network stream submap as the first network stream submap according to the minimum cut partition of the fifth network stream submap Restoring the second node to the fourth network stream submap, and the edge between the second node and all nodes of the third network stream submap becomes the fourth network stream submap The edge between all nodes and all nodes of the third network stream submap.
结合第二方面或第二方面的第一种可能的实现方式或第二方面的第二种可能的实现方式或第二方面的第三种可能的实现方式,在第二方面的第四种可能的实现方式中,还包括:In conjunction with the second aspect or the first possible implementation of the second aspect or the second possible implementation of the second aspect or the third possible implementation of the second aspect, the fourth possibility in the second aspect In the implementation, it also includes:
第一记录单元,用于所述处理单元将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图之后,将所述待处理网络流图的缩减次数进行记录,获得所述待处理网络流图的缩减次数。a first recording unit, configured by the processing unit to form, by the first node, a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow graph Then, the number of times of reduction of the to-be-processed network flow graph is recorded, and the number of times of reduction of the to-be-processed network flow graph is obtained.
结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,还包括:In conjunction with the fourth possible implementation of the second aspect, in a fifth possible implementation of the second aspect, the method further includes:
第一更新单元,用于若所述第一记录单元记录获得的所述待处理网络流图的缩减次数小于第一预设次数,则将所述第一缩减网络流图更新为所述待处理网络流图。a first updating unit, configured to update the first reduced network flow graph to the to-be-processed if the number of times of reduction of the to-be-processed network flow graph obtained by the first recording unit is less than a first preset number of times Network flow diagram.
结合第二方面的第五种可能的实现方式,在第二方面的第六种可能的实现方式中,若所述第一记录单元记录获得的所述待处理网络流图的缩减次数不小于第一预设次数,则所述获取单元,还用于从所述第一缩减网络流图中获取第六网络流子图,所述第六网络流子图包括K个结点和K个结点之间的边,所述K为大于或等于2的整数,所述K个结点中包括第二端点,其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点; With the fifth possible implementation of the second aspect, in a sixth possible implementation manner of the second aspect, if the number of reductions of the to-be-processed network flow graph obtained by the first recording unit record is not less than The acquiring unit is further configured to obtain a sixth network stream submap from the first reduced network flow graph, where the sixth network stream submap includes K nodes and K nodes. Between the edges, the K is an integer greater than or equal to 2, and the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink a node, when the first endpoint is a sink node, the second endpoint is a source node;
所述合并单元,还用于将所述获取单元获取的所述第六网络流子图合并成一个第三结点;The merging unit is further configured to merge the sixth network stream submap obtained by the acquiring unit into a third node;
所述处理单元,还用于将所述合并单元合并获得的所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,所述第七网络流子图由所述第一缩减网络流图中除去所述第六网络流子图之外的所有剩余结点以及所述除去所述第六网络流子图之外的所有剩余结点之间的边组成;所述第六网络流子图的所有结点与所述第七网络流子图的所有结点之间的边,成为所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图包括所述第七网络流子图、所述第三结点、以及所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第三结点为所述第二缩减网络流图的第二端点。The processing unit is further configured to combine the third node obtained by combining the merging unit with a seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph. Diluting a network flow graph, wherein the seventh network stream submap removes all remaining nodes except the sixth network stream submap from the first reduced network flow graph and the removing the sixth network stream a side between all remaining nodes except the sub-picture; the edge between all the nodes of the sixth network stream sub-picture and all the nodes of the seventh network stream sub-picture becomes the third An edge between the node and all nodes of the seventh network stream submap, the second reduced network flow graph including the seventh network stream submap, the third node, and the third An edge between the node and all nodes of the seventh network stream submap, and a minimum cut capacity of the second reduced network flow graph is equal to a minimum cut capacity of the to-be-processed network flow graph, the first The third node is the second endpoint of the second reduced network flow graph.
结合第一方面的第六种可能的实现方式,在第一方面的第七种可能的实现方式中,还包括:In conjunction with the sixth possible implementation of the first aspect, in a seventh possible implementation of the first aspect, the method further includes:
第二记录单元,用于所述处理单元将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图之后,将所述第一缩减网络流图的缩减次数进行记录,获得所述第一缩减网络流图的缩减次数。a second recording unit, configured by the processing unit to form the third node and the seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph to form a second reduced network stream After the figure, the number of reductions of the first reduced network flow graph is recorded, and the number of reductions of the first reduced network flow graph is obtained.
结合第二方面的第七种可能的实现方式,在第二方面的第八种可能的实现方式中,还包括:In conjunction with the seventh possible implementation of the second aspect, in an eighth possible implementation manner of the second aspect, the method further includes:
第二更新单元,用于若所述第二记录单元记录获得的所述第一缩减网络流图的缩减次数小于第二预设次数,则将所述第二缩减网络流图更新为所述第一缩减网络流图。a second updating unit, configured to update the second reduced network flow graph to the first if the number of times of reduction of the first reduced network flow graph obtained by the second recording unit record is less than a second preset number of times A reduced network flow graph.
本发明实施例提供的网络流图缩减方法和装置,通过从待处理网络流图中获取第一网络流子图,再将第一网络流子图合并成一个第一结点,然后将第一结点与待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,第一缩减网络流图的最小割的容量等于待处理网络流图的最小割的容量,第一结点为第一缩减网络流图的第一端点。通过将包括第一端点的M个结点的第一网络流子图合并为第一结点,该第一结点成为缩减后的第一缩减网络流图的第一端点,这样可以有效地缩减图规模,不需要待处理网络流图符合一定的规则,使得对图规模进行缩减的 过程具有普遍的适用性。The network flow graph reduction method and apparatus provided by the embodiment of the present invention obtains the first network stream submap from the to-be-processed network flow graph, and then merges the first network stream submap into a first node, and then the first The second network stream sub-picture in the node and the to-be-processed network flow diagram except the first network stream sub-graph constitutes a first reduced network flow graph, and the minimum cut capacity of the first reduced network flow graph is equal to the to-be-processed network flow graph. The minimum cut capacity, the first node is the first end point of the first reduced network flow graph. By merging the first network stream submap of the M nodes including the first endpoint into the first node, the first node becomes the first endpoint of the reduced first reduced network flow graph, which is effective The size of the map is reduced, and the network flow graph to be processed does not need to meet certain rules, so that the scale of the map is reduced. The process has universal applicability.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1为本发明网络流图缩减方法实施例一的流程图;1 is a flowchart of Embodiment 1 of a network flow graph reduction method according to the present invention;
图2为本发明网络流图缩减方法实施例二的流程图;2 is a flowchart of Embodiment 2 of a network flow graph reduction method according to the present invention;
图3为本发明实施例提供的待处理网络流图的一种示意图;3 is a schematic diagram of a network flow graph to be processed according to an embodiment of the present invention;
图4为本发明实施例提供的第一子图的一种示意图;4 is a schematic diagram of a first sub-picture provided by an embodiment of the present invention;
图5为本发明实施例提供的包括第一结点的第一子图的示意图;FIG. 5 is a schematic diagram of a first sub-picture including a first node according to an embodiment of the present invention; FIG.
图6为本发明实施例提供的第一缩减网络流图的一种示意图;FIG. 6 is a schematic diagram of a first reduced network flow diagram according to an embodiment of the present invention;
图7为本发明网络流图缩减方法实施例三的流程图;7 is a flowchart of Embodiment 3 of a network flow graph reduction method according to the present invention;
图8为本发明网络流图缩减方法实施例四的流程图;8 is a flowchart of Embodiment 4 of a network flow graph reduction method according to the present invention;
图9为本发明网络流图缩减方法实施例五的流程图;9 is a flowchart of Embodiment 5 of a network flow graph reduction method according to the present invention;
图10为本发明网络流图缩减装置实施例一的结构示意图;10 is a schematic structural diagram of Embodiment 1 of a network flow graph reduction device according to the present invention;
图11为本发明网络流图缩减装置实施例二的结构示意图;11 is a schematic structural diagram of Embodiment 2 of a network flow graph reduction device according to the present invention;
图12为本发明网络流图缩减装置实施例三的结构示意图;12 is a schematic structural diagram of Embodiment 3 of a network flow graph reduction device according to the present invention;
图13为本发明网络流图缩减装置实施例四的结构示意图。FIG. 13 is a schematic structural diagram of Embodiment 4 of a network flow graph reduction device according to the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图1为本发明网络流图缩减方法实施例一的流程图,如图1所示,本实施例的方法可以包括:FIG. 1 is a flowchart of Embodiment 1 of a network flow graph reduction method according to the present invention. As shown in FIG. 1 , the method in this embodiment may include:
S101、从待处理网络流图中获取第一网络流子图。S101. Acquire a first network stream submap from the to-be-processed network flow graph.
包括第一端点的M个结点,M为大于等于2的整数,第一端点为待处 理网络流图的源结点或者汇结点。Including M nodes of the first endpoint, M is an integer greater than or equal to 2, and the first endpoint is to be The source node or sink node of the network flow graph.
本实施例中,待处理网络流图为有向图,也是网络流的流向图,待处理网络流图中包括N个结点和N个结点之间的边,N个结点为网络流流经的各个结点,各个结点之间的边表示各个结点之间的网络流关系,N个结点中包括源结点和汇结点,源结点为用以表示待处理网络流图的网络流的起始结点,汇结点为待处理网络流图的网络流的结束结点,并且每个边上具有容量,网络流图可以用于模拟道路系统的交通量、管道中的液体、电路中的电流等等,例如:网络流图中的边可以为水管,网络流为水管中的水,边的容量为水管的容量,水流的源点作为源结点,水流的汇点作为汇结点,任何水管汇合的点为网络流图中除源结点和汇结点之外的结点。也即,网络流图中的网络流均是从源结点流出,最终网络流中的网络流均将流入汇结点,并且,存在流向关系的两结点之间的边均有容量,因此,在边上流动的网络流的流量不能超过该边的容量,从源点流出的网络流的最大流量为该待处理网络流图的最大流,那么该待处理网络流图的最小割的容量与该待处理网络流图的最大流相同。In this embodiment, the network flow graph to be processed is a directed graph and a flow graph of the network flow, and the to-be-processed network flow graph includes edges between N nodes and N nodes, and N nodes are network flows. Each node passing through, the edge between each node represents the network flow relationship between the nodes, the N nodes include the source node and the sink node, and the source node is used to represent the network flow to be processed. The starting node of the network flow of the graph, the sink node is the ending node of the network flow of the network flow graph to be processed, and each side has capacity, and the network flow graph can be used to simulate the traffic volume of the road system and the pipeline. The liquid, the current in the circuit, etc., for example, the side in the network flow diagram can be a water pipe, the network flow is the water in the water pipe, the capacity of the side is the capacity of the water pipe, the source of the water flow serves as the source node, and the sink of the water flow Point as the sink point, the point where any water pipe meets is the node in the network flow graph except the source node and the sink node. That is, the network flows in the network flow graph are all flowing out from the source node, and the network flows in the final network flow will all flow into the sink node, and the edges between the two nodes in the flow direction relationship have a capacity, so The traffic of the network flow flowing on the edge cannot exceed the capacity of the edge, and the maximum traffic of the network flow flowing from the source point is the maximum flow of the to-be-processed network flow graph, and then the minimum cut capacity of the to-be-processed network flow graph The same as the maximum flow of the to-be-processed network flow graph.
本实施例可以获取包括第一网络流子图,该第一网络流子图包括M个结点,M为大于等于2的整数,该M个结点中包括第一端点,第一端点可以为待处理网络流图的源结点或者汇结点,其中,N为大于或等于M的整数。例如:获取的第一网络流子图可以包括待处理网络流图的源结点,获取的第一网络流子图也可以包括待处理网络流图的汇结点。The embodiment may be configured to include a first network stream submap, where the first network stream submap includes M nodes, where M is an integer greater than or equal to 2, and the M nodes include a first endpoint, and the first endpoint It may be a source node or a sink node of a network flow graph to be processed, where N is an integer greater than or equal to M. For example, the acquired first network stream submap may include a source node of the to-be-processed network flow graph, and the obtained first network stream submap may also include a sink node of the to-be-processed network flow graph.
S102、将第一网络流子图合并成一个第一结点。S102. Combine the first network stream submap into a first node.
本实施例中,在获取到第一网络流子图之后,将第一网络流子图合并成一个第一结点,例如:将第一网络流子图缩成一个结点。In this embodiment, after acquiring the first network stream submap, the first network stream submap is merged into a first node, for example, the first network stream submap is reduced to a node.
可选地,将第一网络流子图合并成一个第一结点,可以包括:将第一网络流子图的M个结点之间的边去掉;将M个结点聚合为一个第一结点,具体地,将第一网络流子图的M个结点之间的边去掉,可以认为M个结点之间的网络流关系不存在了,然后将M个结点汇聚为一个结点,该结点称为第一结点。Optionally, combining the first network stream submap into a first node may include: removing an edge between the M nodes of the first network stream submap; and aggregate the M nodes into a first node. Node, specifically, removing the edge between the M nodes of the first network stream sub-picture, it can be considered that the network flow relationship between the M nodes does not exist, and then the M nodes are aggregated into one node. Point, this node is called the first node.
S103、将第一结点与待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,第一缩减网络流图的最小割的容量等于待处理网络流图的最小割的容量,第一结点为第一缩减网络流图的第一 端点。S103. The first network and the second network stream sub-picture except the first network stream sub-picture in the to-be-processed network flow graph are formed into a first reduced network flow graph, where a minimum cut capacity of the first reduced network flow graph is equal to The minimum cut capacity of the network flow graph to be processed, the first node is the first of the first reduced network flow graph End point.
本实施例中,待处理网络流图中除第一网络流子图之外的网络流图可以称为第二网络流子图,该第二网络流子图由待处理网络流图中除去第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;可以根据第一网络流子图的所有结点与第二网络流子图的所有结点之间的边成为第一结点与第二网络流子图的所有结点之间的边,将待处理网络流图中除第一网络流子图之外的第二网络流子图和上述合并得到的第一结点组成一个网络流图,组成后的网络流图称为第一缩减网络流图,得到的第一缩减网络流图包括第一结点、第二网络流子图,以及第一结点与第二网络流子图的所有结点之间的边;若S101中所获取的第一网络流子图中包括的第一端点为源点,那么第一结点就成为第一缩减网络流图的源点;若S101中所获取的第一网络流子图中包括的第一端点为汇点,那么第一结点就成为第一缩减网络流图的汇点。In this embodiment, the network flow graph except the first network stream submap in the to-be-processed network flow graph may be referred to as a second network stream submap, and the second network stream submap is removed from the to-be-processed network flow graph. All remaining nodes except a network stream sub-picture and the edges between all the remaining nodes; may be based on all nodes of the first network stream sub-picture and all nodes of the second network stream sub-picture The edge becomes the edge between the first node and all the nodes of the second network stream sub-picture, and the second network stream sub-picture other than the first network stream sub-picture in the to-be-processed network flow picture is merged with the foregoing The first node constitutes a network flow graph, and the formed network flow graph is referred to as a first reduced network flow graph, and the obtained first reduced network flow graph includes a first node, a second network stream submap, and the first The edge between the node and all the nodes of the second network stream submap; if the first endpoint included in the first network stream subgraph obtained in S101 is the source point, then the first node becomes the first Reducing the source point of the network flow graph; if the first network stream submap obtained in S101 is included End point is the sink node, the first node becomes the first sink down stream network of FIG.
值得注意的是,本实施例中通过上述步骤所获得的第一缩减网络流图的最小割的容量等于待处理网络流图的最小割的容量,而且通过上述步骤所获得的第一缩减网络流图的最大流等于待处理网络流图的最大流。这样第一缩减网络流图的最大流最小割与待处理网络流图的最大流最小割是等价的。It should be noted that the minimum cut capacity of the first reduced network flow graph obtained by the above steps in this embodiment is equal to the minimum cut capacity of the network flow graph to be processed, and the first reduced network flow obtained through the above steps. The maximum flow of the graph is equal to the maximum flow of the network flow graph to be processed. Thus, the maximum flow minimum cut of the first reduced network flow graph is equivalent to the maximum flow minimum cut of the pending network flow graph.
本发明实施例一提供网络流图缩减方法,通过从待处理网络流图中获取第一网络流子图,再将第一网络流子图合并成一个第一结点,然后将第一结点与待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,第一缩减网络流图的最小割的容量等于待处理网络流图的最小割的容量,第一结点为第一缩减网络流图的第一端点。通过将包括M个结点的第一网络流子图合并为第一结点,该第一结点成为缩减后的第一缩减网络流图的第一端点,这样可以有效地缩减图规模,不需要待处理网络流图符合一定的规则,使得对图规模进行缩减的过程具有普遍的适用性。 Embodiment 1 of the present invention provides a network flow graph reduction method, which obtains a first network stream submap from a to-be-processed network flow graph, and then merges the first network stream submap into a first node, and then the first node. And the second network stream submap except the first network stream submap in the to-be-processed network flow graph constitutes a first reduced network flow graph, and the minimum cut capacity of the first reduced network flow graph is equal to the minimum of the to-be-processed network flow graph The cut capacity, the first node is the first end point of the first reduced network flow graph. By merging the first network stream submap including the M nodes into the first node, the first node becomes the first endpoint of the reduced first reduced network flow graph, which can effectively reduce the scale of the graph. There is no need to process the network flow graph to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
图2为本发明网络流图缩减方法实施例二的流程图,如图2所示,本实施例的方法可以包括:2 is a flowchart of Embodiment 2 of a network flow graph reduction method according to the present invention. As shown in FIG. 2, the method in this embodiment may include:
S201、从第一端点开始,搜索获取包括预设个数结点的第三网络流子图。 S201. Starting from the first endpoint, searching for a third network stream submap including a preset number of nodes.
本实施例中,从待处理网络流图的第一端点开始,沿着结点与结点之间的边,来进行搜索获取包括预设个数结点的第三网络流子图,该预设个数结点包括第一端点,搜索获取的第三网络流子图包括搜索获取的预设个数结点和搜索获取的预设个数结点之间的边,需要说明的是,预设个数可以根据实际应用场景而定,本发明实施例在此不做限制。例如:可以从汇结点开始,用反向宽度优先搜索(Breadth First Search,简称:BFS)方法对待处理网络流图进行搜索,获得包括汇结点在内的预设个数的结点第三网络流子图。例如:可以从源结点开始,用BFS方法对待处理网络流图进行搜索,获得包括源结点在内的预设个数据的结点的第三网络流子图。需要说明的是,BFS方法与反向BFS方法与现有技术一致,本发明实施例在此不再赘述。In this embodiment, starting from the first endpoint of the to-be-processed network flow graph, performing a search along the edge between the node and the node to obtain a third network stream submap including a preset number of nodes, where The preset number of nodes includes a first endpoint, and the third network stream submap obtained by the search includes an edge between the preset number of nodes obtained by the search and the preset number of nodes obtained by the search. The preset number may be determined according to the actual application scenario, and the embodiment of the present invention is not limited herein. For example, you can start from the sink point and use the Breadth First Search (BFS) method to search the network flow graph to obtain the preset number of nodes including the sink node. Network stream submap. For example, starting from the source node, the BFS method is used to search the network flow graph to obtain a third network stream submap of the node of the preset data including the source node. It should be noted that the BFS method and the reverse BFS method are consistent with the prior art, and the embodiments of the present invention are not described herein again.
图3为本发明实施例提供的待处理网络流图的一种示意图,如图3所示,该待处理网络流图有编号为0、1、2、3、4、5、6、7、8、9、10的结点,其中,编号为0的结点为源结点,编号为10的结点为汇结点,带箭头的线为结点与结点之间的具有网络流流向的边,边上的数字代表该条边的网络流的容量,即允许流过的最大流量,若预设个数为7个,那么从汇结点(即编号为10的结点)开始,采用反向BFS方法进行搜索,可以搜索到编号为7的结点、编号为8的结点、编号为9的结点、编号为7的结点与编号为10的结点之间的边、编号为8的结点与编号为10的结点之间的边、以及编号为9的结点与编号为10的结点之间的边,然后从编号为7的结点开始采用反向BFS方法进行搜索,可以搜索到编号为4的结点,以及编号为7的结点与编号为5的结点之间的边;从编号为8的结点开始采用反向BFS方法进行搜索,可以搜索到编号为5的结点,以及编号为8的结点与编号为5的结点之间的边;从编号为9的结点开始采用反向BFS方法进行搜索,可以搜索到编号为5的结点、编号为6的结点、编号为5的结点与编号为9的结点之间的边、以及编号为9的结点与编号为6的结点之间的边,从而可以获取一个网络流子图,该该网络流子图包括编号为10的结点在内的7个结点以及该7个结点之间的边,这7个结点分别为编号为4、5、6、7、8、9和10的结点。3 is a schematic diagram of a network flow graph to be processed according to an embodiment of the present invention. As shown in FIG. 3, the network flow graph to be processed has numbers 0, 1, 2, 3, 4, 5, 6, and 7. The nodes of 8, 9, and 10, wherein the node numbered 0 is the source node, the node numbered 10 is the sink node, and the line with the arrow is the network flow direction between the node and the node. The edge, the number on the side represents the capacity of the network stream on the edge, that is, the maximum flow allowed to flow. If the preset number is 7, then it starts from the junction point (that is, the node numbered 10). Using the reverse BFS method to search, you can search for the node numbered 7, the node numbered 8, the node numbered 9, the node between the number 7 and the node numbered 10, The edge between the node numbered 8 and the node numbered 10, and the edge between the node numbered 9 and the node numbered 10, and then the reverse BFS is used from the node numbered 7 Method Search, you can search for the node numbered 4, and the edge between the node numbered 7 and the node numbered 5; the reverse B is used from the node numbered 8 The FS method searches to find the node numbered 5, and the edge between the node numbered 8 and the node numbered 5; the node with the number 9 starts the search using the reverse BFS method. You can search for the node numbered 5, the node numbered 6, the edge between the node numbered 5 and the node numbered 9, and the node numbered 9 and the node numbered 6. The edge between the two, so that a network stream sub-graph can be obtained, the network stream sub-picture includes 7 nodes including the node numbered 10 and the edge between the 7 nodes, respectively, the 7 nodes respectively For nodes numbered 4, 5, 6, 7, 8, 9, and 10.
S202、将待处理网络流图中除第三网络流子图之外的第四网络流子图行合并为一个第二结点。 S202. Combine, in the network flow graph to be processed, the fourth network stream submap other than the third network stream submap into a second node.
本实施例中,将待处理网络流图中除第三网络流子图之外的网络流图作为第四网络流子图,第四网络流子图由待处理网络流图中除去第三网络流子图之外的所有剩余结点以及所述除去第三网络流子图之外的所有剩余结点之间的边组成。In this embodiment, the network flow graph except the third network stream submap in the to-be-processed network flow graph is used as the fourth network stream submap, and the fourth network stream submap is removed from the to-be-processed network flow graph to remove the third network. The remaining nodes other than the stream subgraph and the edges between the remaining nodes except the third network stream subgraph are composed.
可选地,将第四网络流子图合并成一个第二结点,可以包括:将第四网络流子图中的所有结点之间的边去掉;将第四网络流子图的所有结点聚合为一个第一结点,具体地,将第四网络流子图中的所有结点之间的边去掉,可以认为第四网络流子图中的所有结点之间的网络流关系不存在了,然后将第四网络流子图中的所有结点汇聚为一个结点,该结点称为第二结点。Optionally, combining the fourth network stream submap into a second node may include: removing edges between all nodes in the fourth network stream submap; and all nodes of the fourth network stream submap Point aggregation is a first node. Specifically, the edge between all nodes in the fourth network stream submap is removed. It can be considered that the network flow relationship between all nodes in the fourth network stream submap is not It exists, and then all the nodes in the fourth network stream subgraph are aggregated into one node, which is called the second node.
S203、将第二结点与第三网络流子图组成第五网络流子图。S203. The second node and the third network stream sub-picture are combined into a fifth network stream sub-picture.
本实施例中,可以根据第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,将第二结点与上述的第三网络流子图组成一个网络流图,组成后的网络流图称为第五网络流子图,得到的第五网络流子图包括第二结点、第三网络流子图,以及第二结点与第三网络流子图的所有结点之间的边,同时第二结点为第五网络流子图的第二端点。In this embodiment, the second node and the third network stream may be formed according to an edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap. The edge between all the nodes of the graph forms a network flow graph with the second node and the third network stream submap described above, and the formed network flow graph is called a fifth network stream submap, and the obtained fifth network is obtained. The stream subgraph includes a second node, a third network stream sub-picture, and an edge between the second node and all nodes of the third network stream sub-picture, and the second node is a fifth network stream sub-picture The second endpoint.
其中,当第一端点为源结点时,也即从源结点开始,搜索获取包括源结点的第三网络流子图时,那么第二结点可以为第五网络流子图的一个汇结点;当第一端点为汇结点时,也即从汇结点开始,搜索获取包括汇结点的第三网络流子图时,那么第二结点可以成为第五网络流子图的一个源结点。Wherein, when the first endpoint is the source node, that is, starting from the source node, and searching for the third network stream submap including the source node, then the second node may be the fifth network stream submap. a sink node; when the first endpoint is a sink node, that is, starting from the sink node, and searching for a third network stream submap including the sink node, the second node may become the fifth network stream A source node of the subgraph.
图4为本发明实施例提供的第一子图的一种示意图,如图3和图4所示,在获取包括编号为10的汇结点在内的7个结点的网络流子图之后,获取待处理网络流图中除了编号为4、5、6、7、8、9、10的结点之外的结点,也即编号为0、1、2、3的结点,以及编号为0、1、2、3的结点之间的边,去掉编号为0、1、2、3的结点之间的边,将编号为0、1、2、3的结点聚合为一个结点,合并所得到的结点可以称为编号为s*的结点。然后根据搜索获取的网络流子图和第二结点组成第一子图,第一子图包括搜获取的编号为4、5、6、7、8、9、10的结点和编号为s*的结点,以及编号为4、5、6、7、8、9、10、s*的结点之间的边。编号为10的结点为第一子图的第一 端点,编号为s*的结点为第一子图的第二端点,由于编号10的结点为待处理网络汇结点,那么编号为10的结点为第一子图的汇结点,编号为s*的结点为第一子图的源结点。FIG. 4 is a schematic diagram of a first sub-picture according to an embodiment of the present invention. As shown in FIG. 3 and FIG. 4, after acquiring a network stream sub-picture of seven nodes including a junction point numbered 10 Obtaining nodes other than the nodes numbered 4, 5, 6, 7, 8, 9, and 10 in the network flow graph to be processed, that is, nodes numbered 0, 1, 2, and 3, and the number For the edges between the nodes of 0, 1, 2, and 3, remove the edges between the nodes numbered 0, 1, 2, and 3, and aggregate the nodes numbered 0, 1, 2, and 3 into one. Nodes, the nodes obtained by merging can be referred to as nodes numbered s*. Then, the network sub-picture and the second node obtained according to the search form a first sub-picture, and the first sub-picture includes the nodes 4 and 5, 6, 7, 8, 9, 10 obtained by the search, and the number is s. * The node, and the edge between the nodes numbered 4, 5, 6, 7, 8, 9, 10, s*. The node numbered 10 is the first of the first subgraph End point, the node numbered s* is the second end point of the first sub-picture, and since the node numbered 10 is the network connection point to be processed, the node numbered 10 is the sink point of the first sub-picture. The node numbered s* is the source node of the first submap.
S204、根据第五网络流子图的最小割划分,将第五网络流子图的第一最小割子图作为第一网络流子图。S204. The first minimum cut subgraph of the fifth network stream submap is used as the first network stream submap according to the minimum cut partition of the fifth network stream submap.
本实施例中,可以对第五网络流子图的最大流进行计算,获得第五网络流子图的最大流,第五网络流子图的最大流等于第五网络流子图的最小割的容量,从而可以获得第五网络流子图的最小割集合,该最小割集合的容量等于第一子图的最大流,根据第一网络流子图的最小割集合对第五网络流子图进行最小割划分,获得第五网络流子图的最小割,也就是第五网络流子图中去掉最小割集合后得到的两个互不相连的网络流子图,若一个网络流子图包括第五网络流子图的源结点,那么另一个网络流子图包括第五网络流子图的汇结点,同时,两个互不相连的网络流子图可以称为第一最小割子图和第二最小割子图,因此,第五网络流子图的最小割包括第五网络流子图的第一最小割子图的第二最小割子图,然后将第五网络流子图的第一最小割子图作为第一网络流子图,该第一最小割子图包括M个结点,M个结点包括第一端点。由于第一网络流子图为第五网络流子图中的一部分,所以预设个数可以大于或等于M。In this embodiment, the maximum flow of the fifth network stream submap may be calculated to obtain a maximum flow of the fifth network flow submap, and the maximum flow of the fifth network flow submap is equal to the minimum cut of the fifth network flow submap. Capacity, thereby obtaining a minimum cut set of the fifth network stream sub-picture, the capacity of the minimum cut set being equal to the maximum flow of the first sub-picture, and performing the fifth network flow sub-picture according to the minimum cut set of the first network flow sub-picture The minimum cut is obtained, and the minimum cut of the fifth network stream subgraph is obtained, that is, two mutually disconnected network stream subgraphs obtained by removing the minimum cut set in the fifth network stream subgraph, if a network stream subgraph includes the first The source node of the fifth network stream submap, then the other network stream subgraph includes the sink node of the fifth network stream submap, and at the same time, the two disconnected network stream subgraphs may be referred to as the first minimum cut graph. And a second minimum cut subgraph, therefore, the minimum cut of the fifth network stream submap includes a second minimum cut subgraph of the first minimum cut subgraph of the fifth network flow submap, and then the fifth network flow submap First minimum cut subgraph as the first network flow FIG., The first minimum cut subgraph comprises M nodes, M comprises a first end-node. Since the first network stream submap is a part of the fifth network stream submap, the preset number may be greater than or equal to M.
需要说明的是,如何对第五网络流子图进行最大流计算,获得第五网络流子图的最小割集合与现有技术一致,本发明实施例在此不再赘述。It should be noted that, how to perform the maximum stream calculation on the fifth network stream sub-picture, and obtain the minimum cut set of the fifth network stream sub-picture is consistent with the prior art, and details are not repeatedly described herein.
例如:如图4所示,在图4所示的第一子图中,第一子图的最大流为15,那么第一子图的最小割的容量为15,编号为4的结点与编号为7的结点之间的边的容量、编号为5的结点与编号为8的结点之间的边的容量、编号为9的结点与编号为10的结点之间的边的容量,之和为15,那么编号为4的结点与编号为7的结点之间的边、编号为5的结点与编号为8的结点之间的边、编号为9的结点与编号为10的结点之间的边可以统称为第一子图的最小割,那么最小割集合包括编号为7的结点、编号为8的结点和编号为10的结点,或者,最小割集合包括编号为s*的结点、编号为4的结点、编号为5的结点、编号为6的结点和编号为9的结点。因此,根据最小割集合,可以将第一子图划分为第一最小割子图和第二最小割子图,第一最小割子图是由编号为7的结点、编号为8的结点、编号为10的结点, 以及编号为7、8、10的结点之间的边组成,那么第二最小割子图是由编号为s*的结点、编号为4的结点、编号为5的结点、编号为6的结点、编号为9的结点,以及编号为s*、4、5、6、9的结点之间的边组成。For example, as shown in FIG. 4, in the first sub-picture shown in FIG. 4, the maximum flow of the first sub-picture is 15, then the minimum cut capacity of the first sub-picture is 15, and the number is 4 and The capacity of the edge between the nodes numbered 7, the capacity of the edge between the node numbered 5 and the node numbered 8, the edge between the node numbered 9 and the node numbered 10 The capacity, the sum of 15, then the edge between the node numbered 4 and the node numbered 7, the edge between the node numbered 5 and the node numbered 8, the junction numbered 9 The edge between the point and the node numbered 10 can be collectively referred to as the minimum cut of the first subgraph, then the minimum cut set includes the node numbered 7, the node numbered 8 and the node numbered 10, or The minimum cut set includes a node numbered s*, a node numbered 4, a node numbered 5, a node numbered 6 and a node numbered 9. Therefore, according to the minimum cut set, the first sub-picture can be divided into a first minimum cut sub-picture and a second minimum cut sub-picture, and the first minimum cut sub-picture is a node numbered 7 and numbered 8 , the node numbered 10, And the edge composition between the nodes numbered 7, 8, 10, then the second minimum cut subgraph is a node numbered s*, a node numbered 4, a node numbered 5, numbered The node of 6, the node numbered 9, and the edge between the nodes numbered s*, 4, 5, 6, and 9.
S205、将第一网络流子图合并成一个第一结点。S205. Combine the first network stream submap into a first node.
本实施例中,S205的具体实施过程与本发明方法实施例一中的S202的具体实现过程类似,详细可以参见上述实施例中的相关记载,本发明实施例在此不再赘述。In this embodiment, the specific implementation process of S205 is similar to the specific implementation process of S202 in the first embodiment of the present invention. For details, refer to related descriptions in the foregoing embodiments, and details are not described herein again.
例如,图5为本发明实施例提供的包括第一结点的第一子图的示意图,如图5所示,在获得第一最小割子图之后,第一最小割子图是由包括编号为10的汇结点的3个结点以及这3个结点之间的边组成,将第一最小割子图中的编号为7的结点、编号为8的结点、编号为10的结点之间的边去掉,将编号为7的结点、编号为8的结点、编号为10的结点聚合成一个第一结点,该第一结点为编号为t*的结点。For example, FIG. 5 is a schematic diagram of a first sub-picture including a first node according to an embodiment of the present invention. As shown in FIG. 5, after obtaining the first minimum cut sub-picture, the first minimum cut sub-picture is represented by a number. For the 3 nodes of the sink node of 10 and the edge composition between the 3 nodes, the node numbered 7 in the first minimum cut graph, the node numbered 8 is numbered 10 The edge between the nodes is removed, and the node numbered 7, the node numbered 8, and the node numbered 10 are aggregated into a first node, which is the node numbered t*. .
S206、将第二结点还原为第四网络流子图。S206. Restore the second node to a fourth network stream submap.
本实施例中,可以将第二结点进行还原,也即将第二结点还原为待处理网络流图中除第三网络流子图之外的第四网络流子图,也就是将第二结点还原为第四网络流子图中的所有结点,同时还原第四网络流子图中的所有结点之间的边。并且第二结点与第三网络流子图的所有结点之间的边成为第四网络流子图的所有结点与第三网络流子图的所有结点之间的边。In this embodiment, the second node may be restored, that is, the second node is restored to a fourth network stream submap other than the third network stream submap in the to-be-processed network flow graph, that is, the second node. The node is restored to all nodes in the fourth network stream submap, and the edges between all the nodes in the fourth network stream submap are restored. And the edge between the second node and all the nodes of the third network stream sub-picture becomes the edge between all the nodes of the fourth network stream sub-picture and all the nodes of the third network stream sub-picture.
S207、将第一结点与待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图。S207. The first network node and the second network stream sub-picture except the first network stream sub-picture in the to-be-processed network flow graph are combined into a first reduced network flow graph.
本实施例中,S207的具体实现过程与本发明方法实施例一中的S103的具体实现过程类似,详细可以参见上述实施例中的相关记载,本发明实施例在此不再赘述。In this embodiment, the specific implementation process of S207 is similar to the specific implementation process of S103 in the first embodiment of the present invention. For details, refer to related descriptions in the foregoing embodiments, and details are not described herein again.
图6为本发明实施例提供的第一缩减网络流图的一种示意图,如图6所示,在获得第一结点之后,即编号为t*的结点之后,将s*的结点进行还原,也就是将s*的结点还原为编号为0、1、2、3的结点,以及编号为0、1、2、3的结点之间的边。然后将编号为0、1、2、3、4、5、6、9、t*的结点,以及编号为0、1、2、3、4、5、6、9、t*的结点之间的边组成第一缩减网络流图。通过本发明实施例提供的网络流图缩减方法,可以将如图3所示的待处理网络流图缩减为如图6所示的第一缩减网络流图,第一缩减网络 流图与待处理网络流图相比,缩减了两个结点,从而图规模得到了缩减。同时,图3所示的待处理网络流图的最大流为11,也就是待处理网络流图的最小割的容量为11,最小割的容量是编号为0与编号为1的结点之间的边的容量、编号为2与编号为5的结点之间的边的容量、编号为5与编号为9的结点之间的边的容量、编号为9与编号为10的结点之间的边的容量之和。图6所示的第一缩减网络流图的最大流也为11,也就是第一缩减网络流图的最小割的容量为11,最小割的容量也是编号为0与编号为1的结点之间的边的容量、编号为2与编号为5的结点之间的边的容量、编号为5与编号为9的结点之间的边的容量、编号为9与编号为10的结点之间的边的容量之和。因此图3所示的待处理网络流图的最大流最小割等于图6所示的第一缩减网络流图的最大流最小割的最大流最小割,图6所示的第一缩减网络流图等价于图3所示的待处理网络流图。6 is a schematic diagram of a first reduced network flow diagram according to an embodiment of the present invention. As shown in FIG. 6, after obtaining a first node, that is, a node numbered t*, a node of s* is used. The restoration is performed, that is, the node of s* is restored to the node numbered 0, 1, 2, and 3, and the edge between the nodes numbered 0, 1, 2, and 3. Then the nodes numbered 0, 1, 2, 3, 4, 5, 6, 9, t*, and the nodes numbered 0, 1, 2, 3, 4, 5, 6, 9, t* The edges between the components constitute the first reduced network flow graph. The network flow graph reduction method provided by the embodiment of the present invention can reduce the to-be-processed network flow graph shown in FIG. 3 to the first reduced network flow graph shown in FIG. 6 , and the first reduced network. The flow graph is reduced by two nodes compared to the network flow graph to be processed, so that the scale of the graph is reduced. At the same time, the maximum flow of the to-be-processed network flow graph shown in FIG. 3 is 11, that is, the minimum cut capacity of the to-be-processed network flow graph is 11, and the minimum cut capacity is between the node numbered 0 and number 1. The capacity of the side, the capacity of the edge between the number 2 and the node numbered 5, the capacity of the edge between the number 5 and the node numbered 9, and the number 9 and the node numbered 10. The sum of the capacities of the sides. The maximum flow of the first reduced network flow graph shown in FIG. 6 is also 11, that is, the minimum cut capacity of the first reduced network flow graph is 11, and the minimum cut capacity is also the node numbered 0 and numbered 1. The capacity of the side, the capacity of the side between the number 2 and the node numbered 5, the capacity of the side between the number 5 and the node numbered 9, and the number 9 and the number 10 The sum of the capacities between the sides. Therefore, the maximum flow minimum cut of the to-be-processed network flow diagram shown in FIG. 3 is equal to the maximum flow minimum cut of the maximum flow minimum cut of the first reduced network flow diagram shown in FIG. 6, and the first reduced network flow diagram shown in FIG. Equivalent to the network flow graph to be processed shown in Figure 3.
本发明实施例二提供的网络流图缩减方法,通过从第一端点开始,搜索获取包括预设个数结点的第三网络流子图,将待处理网络流图中除第三网络流子图之外的第四网络流子图合并为一个第二结点,将第二结点与第三网络流子图组成第五网络流子图,根据第五网络流子图的最小割划分,将第五网络流子图的第一最小割子图作为第一网络流子图,将第一网络流子图合并成一个第一结点,将第二结点还原为第四网络流子图,将第一结点与待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图。通过将包括M个结点的第一网络流子图合并为第一结点,该第一结点成为缩减后的第一缩减网络流图的第一端点,这样可以有效地缩减图规模,不需要待处理网络流图符合一定的规则,使得对图规模进行缩减的过程具有普遍的适用性。The network flow graph reduction method provided by the second embodiment of the present invention, by searching from the first endpoint, searches for a third network stream submap including a preset number of nodes, and divides the third network stream in the to-be-processed network flow graph. The fourth network stream sub-picture outside the sub-picture is merged into a second node, and the second node and the third network stream sub-picture are combined into a fifth network stream sub-picture, according to the minimum cut of the fifth network stream sub-picture. The first minimum cut subgraph of the fifth network stream submap is used as the first network stream submap, the first network stream submap is merged into one first node, and the second node is restored to the fourth network stream. For example, the first node and the second network stream sub-picture other than the first network stream sub-picture in the to-be-processed network flow graph form a first reduced network flow graph. By merging the first network stream submap including the M nodes into the first node, the first node becomes the first endpoint of the reduced first reduced network flow graph, which can effectively reduce the scale of the graph. There is no need to process the network flow graph to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
图7为本发明网络流图缩减方法实施例三的流程图,如图7所示,本实施例的方法在图1或图2所示的网络流图缩减方法实施例的基础上,还可以包括:FIG. 7 is a flowchart of Embodiment 3 of a network flow graph reduction method according to the present invention. As shown in FIG. 7 , the method in this embodiment may be based on the network flow graph reduction method embodiment shown in FIG. 1 or FIG. 2 . include:
S301、将待处理网络流图的缩减次数进行记录,获得待处理网络流图的缩减次数。S301. Record a reduced number of times of the network flow graph to be processed, and obtain a reduced number of times of the network flow graph to be processed.
本实施例中,每次对待处理网络流图进行缩减处理之后,均对待处理网络流图的缩减次数进行记录,从而可以获得待处理网络流图的总的缩减次数。例如:在对待处理网络流图进行缩减处理之前,将待处理网络流图 的缩减次数记为0,在对待处理网络流图进行缩减处理的时候,将待处理网络流图的缩减次数加1,从而可以获得这次缩减处理之后的待处理网络流图的缩减次数。In this embodiment, after the network flow graph to be processed is reduced, the number of times of reduction of the network flow graph to be processed is recorded, so that the total number of reductions of the network flow graph to be processed can be obtained. For example, the network flow graph to be processed before the network flow graph is to be processed for reduction. The number of reductions is recorded as 0. When the network flow graph to be processed is reduced, the number of reductions of the network flow graph to be processed is incremented by one, so that the number of reductions of the network flow graph to be processed after the reduction processing can be obtained.
S302、判断待处理网络流图的缩减次数是否小于第一预设次数,若是,则执行S303,若否,则执行S304。S302. Determine whether the number of times of reduction of the to-be-processed network flow graph is less than the first preset number of times. If yes, execute S303. If no, execute S304.
本实施例中,在获得待处理网络流图的缩减次数之后,判断待处理网络流图的缩减次数是否小于第一预设次数,若小于,则说明还可以对待处理网络流图进行缩减处理,也即执行S303,若不小于,则说明可以不再对待处理网络流图进行缩减处理,也即执行S304。第一预设次数可以为用户设置的迭代次数,也可以为系统缺省的迭代次数,第一预设次数可以根据实际的应用场景而定,本发明实施例在此不做限制。In this embodiment, after obtaining the reduced number of times of the network flow graph to be processed, determining whether the number of times of reduction of the network flow graph to be processed is less than the first preset number of times, if it is smaller, it indicates that the network flow graph to be processed may be reduced. That is, S303 is executed. If it is not less than, it means that the network flow graph to be processed is not reduced, that is, S304 is executed. The first preset number of times may be the number of iterations set by the user, or may be the default number of iterations of the system. The first preset number of times may be determined according to an actual application scenario, which is not limited herein.
S303、将第一缩减网络流图更新为待处理网络流图。S303. Update the first reduced network flow graph to a network flow graph to be processed.
本实施例中,若待处理网络流图的缩减次数小于第一预设次数,则说明还可以对待处理网络流图进行缩减处理,然后将第一缩减网络流图更新为待处理网络流图,也即再执行S101-S103或者再执行S201-S207。In this embodiment, if the number of times of reduction of the network flow graph to be processed is less than the first preset number of times, it indicates that the network flow graph to be processed may be reduced, and then the first reduced network flow graph is updated to the network flow graph to be processed. That is, S101-S103 is executed again or S201-S207 is executed again.
S304、结束流程。S304. End the process.
本实施例中,若待处理网络流图的缩减次数不小于第一预设次数,则说明可以不再对待处理网络流图进行缩减处理,然后结束流程。In this embodiment, if the number of times of reduction of the network flow graph to be processed is not less than the first preset number of times, it indicates that the network flow graph to be processed is not reduced, and then the process ends.
在第一种可行的实现方式中,第一端点为源结点时,也就是每次均从待处理网络流图的源结点开始对待处理网络流图进行缩减,即从待处理网络流图的源结点开始对待处理网络流图进行第一预设次数的缩减。In the first feasible implementation manner, when the first endpoint is the source node, that is, the processing network flow graph is reduced from the source node of the to-be-processed network flow graph each time, that is, from the network stream to be processed. The source node of the graph begins to process the network flow graph for a first predetermined number of reductions.
在第二种可行的实现方式中,第一端点为汇结点时,也就是每次均从待处理网络流图的汇结点开始对待处理网络流图进行缩减,即从待处理网络流图的汇结点开始对待处理网络流图进行第一预设次数的缩减。In a second feasible implementation manner, when the first endpoint is a sink node, that is, each time the processing network flow graph is reduced from the sink point of the to-be-processed network flow graph, that is, the network flow to be processed is The sink point of the graph begins to process the network flow graph for a first predetermined number of reductions.
需要说明的是,在第一预设次数设置合适的时候,可以将待处理网络流图缩减成两个结点,一个结点为源结点,另一个结点是由最小割子图合并而成的结点,即新的汇结点,那么源结点与新的汇结点之间的边就是最小割集合。或者,一个结点为汇结点,另一个结点是由最小割子图合并而成的结点,即新的源结点,那么新的源结点与汇结点之间的边就是最小割集合。It should be noted that when the first preset number of times is set properly, the network flow graph to be processed can be reduced to two nodes, one node is the source node, and the other node is merged by the minimum cut subgraph. The resulting node, the new sink node, then the edge between the source node and the new sink node is the minimum cut set. Or, one node is a sink node, and the other node is a node merged by a minimum cut subgraph, that is, a new source node, then the edge between the new source node and the sink node is the smallest Cut the collection.
本发明实施例三提供的网络流图缩减方法,进一步地,通过将待处理 网络流图的缩减次数进行记录,获得待处理网络流图的缩减次数,若待处理网络流图的缩减次数小于第一预设次数,则将第一缩减网络流图更新为待处理网络流图,再进行缩减处理。这样可以有效并且大量地缩减图规模,不需要待处理网络流图符合一定的规则,使得对图规模进行缩减的过程具有普遍的适用性。The network flow graph reduction method provided by the third embodiment of the present invention is further processed by The number of times of reduction of the network flow graph is recorded, and the number of times of the network flow graph to be processed is reduced. If the number of times of the network flow graph to be processed is less than the first preset number, the first reduced network flow graph is updated to the network flow graph to be processed. , then reduce the processing. This can effectively and greatly reduce the scale of the graph, and does not require the network flow graph to be processed to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
图8为本发明网络流图缩减方法实施例四的流程图,如图8所示,本实施例的方法在图1-图3所示的任一网络流图缩减方法实施例的基础上,还可以包括:FIG. 8 is a flowchart of Embodiment 4 of a network flow graph reduction method according to the present invention. As shown in FIG. 8 , the method in this embodiment is based on any embodiment of the network flow graph reduction method shown in FIG. 1 to FIG. 3 . It can also include:
S401、从第一缩减网络流图中获取第六网络流子图。S401. Acquire a sixth network stream submap from the first reduced network flow graph.
其中,第六网络流子图包括K个结点和K个结点之间的边,K为大于或等于2的整数,当第一端点为源结点时,第二端点为汇结点,当第一端点为汇结点时,第二端点为源结点。The sixth network stream submap includes an edge between the K nodes and the K nodes, and K is an integer greater than or equal to 2. When the first endpoint is the source node, the second endpoint is the sink node. When the first endpoint is a sink node, the second endpoint is a source node.
S402、将第六网络流子图合并成一个第三结点。S402. Combine the sixth network stream submap into a third node.
S403、将第三结点与第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图。S403. The third node and the seventh network stream submap except the sixth network stream submap in the first reduced network flow graph form a second reduced network flow graph.
其中,第七网络流子图由第一缩减网络流图中除去第六网络流子图之外的所有剩余结点以及所述除去第六网络流子图之外的所有剩余结点之间的边组成;第六网络流子图的所有结点与第七网络流子图的所有结点之间的边,成为第三结点与第七网络流子图的所有结点之间的边,第二缩减网络流图包括第七网络流子图、第三结点、以及第三结点与第七网络流子图的所有结点之间的边,第二缩减网络流图的最小割的容量等于待处理网络流图的最小割的容量,第三结点为第二缩减网络流图的第二端点。Wherein the seventh network stream submap is removed from all remaining nodes except the sixth network stream submap in the first reduced network flow graph and all remaining nodes except the sixth network stream submap Edge composition; the edge between all nodes of the sixth network stream subgraph and all nodes of the seventh network stream subgraph becomes the edge between all nodes of the third node and the seventh network stream subgraph, The second reduced network flow graph includes a seventh network stream submap, a third node, and an edge between all nodes of the third node and the seventh network stream submap, and the second reduced network flow graph is minimally cut. The capacity is equal to the minimum cut capacity of the network flow graph to be processed, and the third node is the second end point of the second reduced network flow graph.
本发明实施例中的S401-S403的具体实现过程与本发明方法实施例一中的S101-S103的具体实现过程类似,或者,本发明实施例中的S401-S403的具体实现过程与本发明方法实施例二中的S201-S207的具体实现过程类似,详细可以参见上述实施例中的相关记载,本发明实施例在此不再赘述。The specific implementation process of S401-S403 in the embodiment of the present invention is similar to the specific implementation process of S101-S103 in the first embodiment of the present invention, or the specific implementation process of S401-S403 in the embodiment of the present invention and the method of the present invention The specific implementation process of the S201-S207 in the second embodiment is similar. For details, refer to the related description in the foregoing embodiment, and details are not described herein again.
在一种可行的实现方式中,可以从待处理网络流图的源结点开始,对待处理网络流图进行一次缩减处理,获得第一缩减网络流图;然后从第一缩减网络流图的汇结点开始,对第一缩减网络流图进行一次缩减处理,获得第二缩减网络流图;然后将第二缩减网络流图更新为待处理网络流图,从更新后的待处理网络流图的源结点开始,对更新的待处理的网络流图进 行一次缩减处理,获得一个第一缩减网络流图;然后从该第一缩减网络流图的汇结点开始,对第一缩减网络流图进行一次缩减处理,获得第二缩减网络流图;以此类推,一次从源结点开始进行缩减处理,一次从汇结点开始进行缩减处理。或者,可以从待处理网络流图的汇结点开始,对待处理网络流图进行一次缩减处理,获得第一缩减网络流图;然后从第一缩减网络流图的源结点开始,对第一缩减网络流图进行一次缩减处理,获得第二缩减网络流图;然后将第二缩减网络流图更新为待处理网络流图,从更新后的待处理网络流图的汇结点开始,对更新的待处理的网络流图进行一次缩减处理,获得一个第一缩减网络流图;然后从该第一缩减网络流图的源结点开始,对第一缩减网络流图进行一次缩减处理,获得第二缩减网络流图;以此类推,一次从汇结点开始进行缩减处理,一次从源结点开始进行缩减处理。在缩减处理次数合适的情况下,可以将待处理网络流图缩减成两个结点,一个结点为由最小割子图合并而成的结点,即新的源结点,另一个结点也是由最小割子图合并而成的结点,即新的汇结点,那么新的源结点与新的汇结点之间的边就是最小割。In a feasible implementation manner, starting from a source node of the network flow graph to be processed, the network flow graph to be processed is subjected to a reduction process to obtain a first reduced network flow graph; and then the sink is reduced from the first network flow graph. At the beginning of the node, the first reduced network flow graph is subjected to a reduction process to obtain a second reduced network flow graph; and then the second reduced network flow graph is updated to the pending network flow graph, from the updated pending network flow graph. The source node starts, and the updated network flow graph to be processed Performing a reduction process to obtain a first reduced network flow graph; then, starting from the sink point of the first reduced network flow graph, performing a reduction process on the first reduced network flow graph to obtain a second reduced network flow graph; In this way, the reduction process is performed from the source node at a time, and the reduction process is started from the sink node at a time. Alternatively, starting from the sink point of the network flow graph to be processed, the network flow graph to be processed is subjected to a reduction process to obtain a first reduced network flow graph; and then starting from the source node of the first reduced network flow graph, the first The network flow graph is reduced to perform a reduction process to obtain a second reduced network flow graph; then the second reduced network flow graph is updated to be a pending network flow graph, starting from the sink point of the updated pending network flow graph, and updating The to-be-processed network flow graph is subjected to a reduction process to obtain a first reduced network flow graph; and then, starting from the source node of the first reduced network flow graph, the first reduced network flow graph is subjected to a reduction process to obtain the first Second, the network flow graph is reduced; and so on, the reduction processing is started from the sink node once, and the reduction processing is performed from the source node at a time. In the case that the number of times of reduction processing is appropriate, the network flow graph to be processed can be reduced to two nodes, and one node is a node formed by merging the smallest cut sub-pictures, that is, a new source node and another node. It is also the node that is merged by the smallest cut subgraph, that is, the new sink point, then the edge between the new source node and the new sink point is the minimum cut.
在另一种可行的实现方式中,可以从待处理网络流图的源结点开始,对待处理网络流图进行缩减处理,当待处理网络流图的缩减次数不小于第一预设次数,则说明可以不再从源结点开始对待处理网流图进行缩减处理,然后从缩减处理得到的第一缩减网络流图的汇结点开始,对第一缩减网络流图进行缩减处理。或者,可以从待处理网络流图的汇结点开始,对待处理网络流图进行缩减处理,当待处理网络流图的缩减次数不小于第一预设次数,则说明可以不再从汇结点开始对待处理网流图进行缩减处理,然后从缩减处理得到的第一缩减网络流图的源结点开始,对第一缩减网络流图进行缩减处理。In another feasible implementation manner, the network flow graph to be processed may be reduced from the source node of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, The description may stop reducing the processing of the network flow graph from the source node, and then reduce the first reduced network flow graph from the sink point of the first reduced network flow graph obtained by the reduction processing. Alternatively, the network flow graph to be processed may be reduced from the sink point of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, the slave node may no longer be removed from the sink node. The processing of the network flow graph is started to be reduced, and then the first reduced network flow graph is reduced from the source node of the first reduced network flow graph obtained by the reduction processing.
本发明实施例四提供的网络流图缩减方法,进一步地,通过从第一缩减网络流图中获取第六网络流子图;将第六网络流子图合并成一个第三结点;将第三结点与第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,第二缩减网络流图的最小割的容量等于待处理网络流图的最小割的容量,第三结点为第二缩减网络流图的第二端点。通过将包括K个结点的第六网络流子图合并为第三结点,该第三结点成为缩减后的第二缩减网络流图的第二端点,这样可以有效地缩减图规模,不 需要待处理网络流图符合一定的规则,使得对图规模进行缩减的过程具有普遍的适用性。The network flow graph reduction method provided by Embodiment 4 of the present invention further includes: obtaining a sixth network stream submap from the first reduced network flow graph; and merging the sixth network stream submap into a third node; The third node and the seventh network stream submap except the sixth network stream submap in the first reduced network flow graph form a second reduced network flow graph, and the minimum cut capacity of the second reduced network flow graph is equal to the network to be processed. The minimum cut capacity of the flow graph, and the third node is the second end point of the second reduced network flow graph. By merging the sixth network stream submap including K nodes into a third node, the third node becomes the second endpoint of the reduced second reduced network flow graph, which can effectively reduce the scale of the graph, The network flow graph to be processed needs to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
图9为本发明网络流图缩减方法实施例五的流程图,如图9所示,本实施例的方法在图8所示的网络流图缩减方法实施例的基础上,还可以包括:FIG. 9 is a flowchart of Embodiment 5 of a network flow graph reduction method according to the present invention. As shown in FIG. 9 , the method in this embodiment may further include:
S501、将第一缩减网络流图的缩减次数进行记录,获得第一缩减网络流图的缩减次数。S501. Record the reduced number of times of the first reduced network flow graph, and obtain the reduced number of times of the first reduced network flow graph.
本实施例中,每次对第一缩减网络流图进行缩减处理之后,均对第一缩减网络流图的缩减次数进行记录,从而可以获得第一缩减网络流图的总的缩减次数。例如:在对第一缩减网络流图进行缩减处理之前,将第一缩减网络流图的缩减次数记为0,在对第一缩减网络流图进行缩减处理的时候,将第一缩减网络流图的缩减次数加1,从而可以获得这次缩减处理之后的第一缩减网络流图的缩减次数。In this embodiment, each time the first reduced network flow graph is reduced, the number of times of reduction of the first reduced network flow graph is recorded, so that the total number of reductions of the first reduced network flow graph can be obtained. For example, before the first reduced network flow graph is reduced, the number of reductions of the first reduced network flow graph is recorded as 0, and when the first reduced network flow graph is reduced, the first reduced network flow graph is obtained. The number of reductions is incremented by one, so that the number of reductions of the first reduced network flow graph after this reduction process can be obtained.
S502、判断第一缩减网络流图的缩减次数是否小于第二预设次数,若是,则执行S503,若否,则执行S504。S502. Determine whether the number of times of reduction of the first reduced network flow graph is less than a second preset number. If yes, execute S503. If no, execute S504.
本实施例中,在获得第一缩减网络流图的缩减次数之后,判断第一缩减网络流图的缩减次数是否小于第二预设次数,若小于,则说明还可以对第一缩减网络流图进行缩减处理,也即执行S503,若不小于,则说明可以不再对第一缩减网络流图进行缩减处理,也即执行S504。第二预设次数可以为用户设置的迭代次数,也可以为系统缺省的迭代次数,第二预设次数可以根据实际的应用场景而定,本发明实施例在此不做限制。In this embodiment, after obtaining the reduced number of times of the first reduced network flow graph, determining whether the number of times of reduction of the first reduced network flow graph is less than a second preset number of times, and if less than, indicating that the first reduced network flow graph is further The reduction processing is performed, that is, S503 is executed. If it is not smaller, it means that the first reduced network flow graph can no longer be reduced, that is, S504 is executed. The second preset number of times may be the number of iterations set by the user, and may be the default number of iterations of the system. The second preset number of times may be determined according to an actual application scenario, which is not limited herein.
S503、将第二缩减网络流图更新为第一缩减网络流图。S503. Update the second reduced network flow graph to the first reduced network flow graph.
本实施例中,若第一缩减网络流图的缩减次数小于第二预设次数,则说明还可以对第一缩减网络流图进行缩减处理,然后将第二缩减网络流图更新为第一缩减网络流图,也即再执行S401-S403。In this embodiment, if the number of times of reduction of the first reduced network flow graph is less than the second preset number of times, it may be further that the first reduced network flow graph may be reduced, and then the second reduced network flow graph is updated to the first reduced The network flow graph, that is, S401-S403 is executed again.
S504、结束流程。S504, ending the process.
本实施例中,若第一缩减网络流图的缩减次数不小于第二预设次数,则说明可以不再对第一缩减网络流图进行缩减处理,然后结束流程。In this embodiment, if the number of times of reduction of the first reduced network flow graph is not less than the second preset number of times, it may be that the first reduced network flow graph may not be reduced, and then the process ends.
在第一种可行的实现方式中,可以从待处理网络流图的源结点开始,对待处理网络流图进行缩减处理,当待处理网络流图的缩减次数不小于第一预设次数时,说明可以不再从源结点开始对待处理网流图进行缩减处理, 然后从缩减处理得到的第一缩减网络流图的汇结点开始,对第一缩减网络流图进行缩减处理,当第一缩减网络流图的缩减次数不小于第二预设次数,则说明可以不再从汇结点开始对待处理网流图进行缩减处理,即完成缩减处理,结束流程。或者,可以从待处理网络流图的汇结点开始,对待处理网络流图进行缩减处理,当待处理网络流图的缩减次数不小于第一预设次数时,说明可以不再从汇结点开始对待处理网流图进行缩减处理,然后从缩减处理得到的第一缩减网络流图的源结点开始,对第一缩减网络流图进行缩减处理,当第一缩减网络流图的缩减次数不小于第二预设次数,则说明可以不再从源结点开始对待处理网流图进行缩减处理,即完成缩减处理,结束流程。在缩减处理次数合适的情况下,可以将待处理网络流图缩减成两个结点,两个结点分别为由不同的最小割子图合并而成的结点,即新的源结点和新的汇结点,那么新的源结点与新的汇结点之间的边就是最小割集合。In the first feasible implementation manner, the network flow graph to be processed may be reduced from the source node of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, The description can no longer reduce the processing of the network flow graph from the source node. Then, starting from the sink point of the first reduced network flow graph obtained by the reduction process, the first reduced network flow graph is reduced, and when the number of reductions of the first reduced network flow graph is not less than the second preset number, The processing of the network flow graph is no longer reduced from the sink node, that is, the reduction processing is completed, and the flow is ended. Alternatively, the network flow graph to be processed may be reduced from the sink point of the network flow graph to be processed, and when the number of times of the network flow graph to be processed is not less than the first preset number, the description may no longer be from the sink node. Start to process the network flow graph for reduction processing, and then reduce the first reduced network flow graph from the source node of the first reduced network flow graph obtained by the reduction processing, when the first reduced network flow graph is reduced by a small number of times If the second preset number is less than the second preset number, it may be that the network flow graph to be processed is not reduced from the source node, that is, the reduction processing is completed, and the flow is ended. In the case that the number of times of reduction processing is appropriate, the network flow graph to be processed can be reduced to two nodes, and the two nodes are respectively nodes merged by different minimum cut sub-graphs, that is, new source nodes and The new sink point, then the edge between the new source node and the new sink node is the minimum cut set.
在第二种可行的实现方式中,可以从待处理网络流图的源结点开始,对待处理网络流图进行缩减处理,然后从缩减处理得到的第一缩减网络流图的汇结点开始,对第一缩减网络流图进行缩减处理,当第一缩减网络流图的缩减次数不小于第二预设次数,则说明可以不再从汇结点开始对待处理网流图进行缩减处理,即完成缩减处理,结束流程。或者,可以从待处理网络流图的汇结点开始,对待处理网络流图进行缩减处理,然后从缩减处理得到的第一缩减网络流图的源结点开始,对第一缩减网络流图进行缩减处理,当第一缩减网络流图的缩减次数不小于第二预设次数,则说明可以不再从源结点开始对待处理网流图进行缩减处理,即完成缩减处理,结束流程。In a second feasible implementation manner, the network flow graph to be processed may be reduced from the source node of the network flow graph to be processed, and then the sink point of the first reduced network flow graph obtained by the reduction processing is started. The reduction of the first reduced network flow graph is performed. When the number of reductions of the first reduced network flow graph is not less than the second preset number of times, it indicates that the network flow graph to be processed may not be reduced from the sink node, that is, completed. Reduce processing and end the process. Alternatively, the network flow graph to be processed may be reduced from the sink point of the network flow graph to be processed, and then the first reduced network flow graph is started from the source node of the first reduced network flow graph obtained by the reduction processing. The reduction processing, when the number of reductions of the first reduced network flow graph is not less than the second preset number of times, indicates that the network flow graph to be processed may not be reduced from the source node, that is, the reduction processing is completed, and the flow is ended.
本发明实施例五提供的网络流图缩减方法,进一步地,通过将第一缩减网络流图的缩减次数进行记录,获得第一缩减网络流图的缩减次数;当第一缩减网络流图的缩减次数小于第二预设次数时,将第二缩减网络流图更新为第一缩减网络流图,再进行缩减处理。这样可以有效并且大量地缩减图规模,不需要待处理网络流图符合一定的规则,使得对图规模进行缩减的过程具有普遍的适用性。The network flow graph reduction method provided by the fifth embodiment of the present invention further obtains the reduced number of times of the first reduced network flow graph by recording the reduced number of times of the first reduced network flow graph; when the first reduced network flow graph is reduced When the number of times is less than the second preset number of times, the second reduced network flow graph is updated to the first reduced network flow graph, and then the reduction processing is performed. This can effectively and greatly reduce the scale of the graph, and does not require the network flow graph to be processed to meet certain rules, so that the process of reducing the scale of the graph has universal applicability.
图10为本发明网络流图缩减装置实施例一的结构示意图,如图10所示,本实施例的装置可以包括:获取单元11、合并单元12和处理单元13, 其中,获取单元11用于从待处理网络流图中获取第一网络流子图,所述第一网络流子图包括M个结点和M个结点之间的边,所述M个结点中包括第一端点,所述M为大于或等于2的整数,所述待处理网络流图包括N个结点和N个结点之间的边,所述N个结点中包括源结点和汇结点,所述N为大于M的整数,所述第一端点为源结点或者汇结点,所述源结点为用以表示所述待处理网络流图的网络流的起始结点,所述汇结点为所述网络流的结束结点,其中,各个结点之间的边表示各个结点之间的网络流关系;合并单元12用于将获取单元11获取的第一网络流子图合并成一个第一结点;处理单元13用于将合并单元12合并获得的所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,所述第二网络流子图由所述待处理网络流图中除去所述第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;所述第一网络流子图的所有结点与所述第二网络流子图的所有结点之间的边成为所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图包括所述第一结点、所述第二网络流子图,以及所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第一结点为所述第一缩减网络流图的第一端点。FIG. 10 is a schematic structural diagram of Embodiment 1 of a network flow graph reduction apparatus according to the present invention. As shown in FIG. 10, the apparatus in this embodiment may include: an obtaining unit 11, a merging unit 12, and a processing unit 13, The obtaining unit 11 is configured to obtain a first network stream submap from the to-be-processed network flow graph, where the first network stream submap includes edges between the M nodes and the M nodes, and the M nodes The point includes a first endpoint, the M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes an edge between the N nodes and the N nodes, where the N nodes include a source a node and a sink node, where N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is a network flow used to represent the to-be-processed network flow graph The starting node, the sink node is an end node of the network flow, wherein an edge between each node represents a network flow relationship between the nodes; a merging unit 12 is configured to acquire the unit 11 The acquired first network stream sub-graphs are merged into one first node; the processing unit 13 is configured to merge the first nodes obtained by combining the merging unit 12 with the first network stream sub-picture in the to-be-processed network flow graph. a second network stream submap other than the first network flow graph, the second network stream submap being divided by the to-be-processed network flow graph All remaining nodes outside the first network stream sub-picture and edges between the remaining nodes; all nodes of the first network stream sub-picture and the second network stream sub-picture An edge between all nodes becomes an edge between the first node and all nodes of the second network stream submap, the first reduced network flow graph including the first node, the a second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum cut capacity of the first reduced network flow graph is equal to the to-be-processed The minimum cut capacity of the network flow graph, the first node being the first endpoint of the first reduced network flow graph.
本实施例的装置,可以用于执行本发明上述方法实施例的技术方案,其实现原理和技术效果类似,详细可以参见本发明上述实施例中的相关记载,此处不再赘述。The device in this embodiment may be used to perform the technical solution of the foregoing method embodiment of the present invention. The implementation principle and the technical effect are similar. For details, refer to related descriptions in the foregoing embodiments of the present invention, and details are not described herein again.
图11为本发明网络流图缩减装置实施例二的结构示意图,如图11所示,本实施例的装置在图10所示装置结构的基础上,可选地,合并单元12具体用于将所述第一网络流子图的M个结点之间的边去掉,并将所述M个结点聚合为一个所述第一结点。FIG. 11 is a schematic structural diagram of Embodiment 2 of a network flow graph reduction device according to the present invention. As shown in FIG. 11 , the device in this embodiment is based on the device structure shown in FIG. 10 , and optionally, the merging unit 12 is specifically configured to An edge between the M nodes of the first network stream submap is removed, and the M nodes are aggregated into one of the first nodes.
可选地,获取单元11具体用于从所述第一端点开始,搜索获取包括预设个数结点的第三网络流子图,所述第三网络流子图包括所述搜索获取的所述预设个数结点和所述搜索获取的所述预设个数结点之间的边,所述预设个数大于或等于所述M;将所述待处理网络流图中除所述第三网络流子图之外的第四网络流子图合并为一个第二结点,所述第四网络流子图由所述待处理网络流图中除去所述第三网络流子图之外的所有剩余结点以及所 述除去所述第三网络流子图之外的所有剩余结点之间的边组成;并将所述第二结点与所述第三网络流子图组成第五网络流子图,所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,所述第五网络流子图包括所述第二结点、所述第三网络流子图以及所述第二结点与所述第三网络流子图的所有结点之间的边,所述第二结点为所述第五网络流子图的第二端点;其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图。Optionally, the obtaining unit 11 is specifically configured to: start from the first endpoint, search for a third network stream submap including a preset number of nodes, where the third network stream submap includes the search An edge between the preset number of nodes and the preset number of nodes obtained by the search, the preset number is greater than or equal to the M; and the network flow graph to be processed is divided The fourth network stream submap outside the third network stream submap is merged into a second node, and the fourth network stream submap is removed from the to-be-processed network flow graph by the third network stream All remaining nodes outside the graph and Determining an edge composition between all remaining nodes except the third network stream submap; and forming the second node and the third network stream submap into a fifth network stream submap, An edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap becomes between the second node and all nodes of the third network stream submap The fifth network stream submap includes the second node, the third network stream submap, and all nodes between the second node and the third network stream submap The second node is a second endpoint of the fifth network stream submap; wherein, when the first endpoint is a source node, the second endpoint is a sink node, when When the first endpoint is a sink node, the second endpoint is a source node; according to the minimum cut partition of the fifth network stream submap, the first minimum cut graph of the fifth network stream submap is As the first network stream submap.
可选地,本实施例的装置还可以包括:还原单元14,该还原单元14用于获取11根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图之后,将所述第二结点还原为所述第四网络流子图,所述第二结点与所述第三网络流子图的所有结点之间的边成为所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边。Optionally, the apparatus in this embodiment may further include: a restoring unit 14 configured to obtain, according to a minimum cut partition of the fifth network stream submap, the fifth network stream submap. After the minimum cut subgraph is used as the first network stream submap, the second node is restored to the fourth network stream submap, and the second node and the third network stream submap are The edge between all nodes becomes the edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap.
可选地,本实施例的装置还可以包括:第一记录单元15,该第一记录单元15用于处理单元13将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图之后,将所述待处理网络流图的缩减次数进行记录,获得所述待处理网络流图的缩减次数。Optionally, the apparatus in this embodiment may further include: a first recording unit 15 configured by the processing unit 13 to divide the first node and the to-be-processed network flow diagram except the first network After the second network stream submap other than the stream submap constitutes the first reduced network flow graph, the number of times of the to-be-processed network flow graph is reduced, and the number of times of the to-be-processed network flow graph is obtained.
可选地,本实施例的装置还可以包括:第一更新单元16,该第一更新单元16用于若第一记录单元15记录获得的所述待处理网络流图的缩减次数小于第一预设次数,则将所述第一缩减网络流图更新为所述待处理网络流图。Optionally, the apparatus of this embodiment may further include: a first updating unit 16, where the first update unit 16 is configured to reduce the number of times of the to-be-processed network flow graph obtained by the first recording unit 15 to be less than the first pre- And setting the number of times, updating the first reduced network flow graph to the to-be-processed network flow graph.
本实施例的装置,可以用于执行本发明上述方法实施例的技术方案,其实现原理和技术效果类似,详细可以参见本发明上述实施例中的相关记载,此处不再赘述。The device in this embodiment may be used to perform the technical solution of the foregoing method embodiment of the present invention. The implementation principle and the technical effect are similar. For details, refer to related descriptions in the foregoing embodiments of the present invention, and details are not described herein again.
图12为本发明网络流图缩减装置实施例三的结构示意图,如图12所示,本实施例的装置在图11所示装置结构的基础上,进一步地,若第一记录单元15记录获得的所述待处理网络流图的缩减次数不小于第一预设次数,则获取单元11还用于从所述第一缩减网络流图中获取第六网络流子图, 所述第六网络流子图包括K个结点和K个结点之间的边,所述K为大于或等于2的整数,所述K个结点中包括第二端点,其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;合并单元12,还用于将获取单元11获取到的所述第六网络流子图合并成一个第三结点;处理单元13,还用于将合并单元12合并获得的所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,所述第七网络流子图由所述第一缩减网络流图中除去所述第六网络流子图之外的所有剩余结点以及所述除去所述第六网络流子图之外的所有剩余结点之间的边组成;所述第六网络流子图的所有结点与所述第七网络流子图的所有结点之间的边,成为所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图包括所述第七网络流子图、所述第三结点、以及所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第三结点为所述第二缩减网络流图的第二端点。FIG. 12 is a schematic structural diagram of Embodiment 3 of a network flow graph reduction apparatus according to the present invention. As shown in FIG. 12, the apparatus of this embodiment is based on the apparatus structure shown in FIG. 11, and further, if the first recording unit 15 records and obtains The obtaining unit 11 is further configured to obtain the sixth network stream submap from the first reduced network flow graph, where the number of times of the to-be-processed network flow graph is not smaller than the first preset number of times. The sixth network stream submap includes edges between K nodes and K nodes, the K is an integer greater than or equal to 2, and the K nodes include a second endpoint, where When the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node; the merging unit 12 is further used Combining the sixth network stream sub-graph obtained by the obtaining unit 11 into a third node; the processing unit 13 is further configured to merge the third node obtained by the merging unit 12 with the first reduction The seventh network stream submap in addition to the sixth network stream submap in the network flow graph constitutes a second reduced network flow graph, wherein the seventh network stream submap is removed from the first reduced network flow graph All remaining nodes other than the six network stream sub-pictures and the edges between the remaining nodes except the sixth network stream sub-picture are deleted; all nodes of the sixth network stream sub-picture are An edge between all nodes of the seventh network stream submap becomes all nodes of the third node and the seventh network stream submap The second reduced network flow graph includes the seventh network stream submap, the third node, and all nodes of the third node and the seventh network stream submap An edge between the second reduced network flow graph having a minimum cut capacity equal to a minimum cut capacity of the to-be-processed network flow graph, the third node being a second of the second reduced network flow graph End point.
可选地,本实施例的装置还可以包括:第二记录单元17,该第二记录单元17,用于处理单元13将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图之后,将所述第一缩减网络流图的缩减次数进行记录,获得所述第一缩减网络流图的缩减次数。Optionally, the apparatus of this embodiment may further include: a second recording unit 17, configured by the processing unit 13 to divide the third node from the first reduced network flow graph After the seventh network stream submap other than the six network stream submaps constitutes the second reduced network flow graph, the number of reductions of the first reduced network flow graph is recorded, and the number of reductions of the first reduced network flow graph is obtained. .
可选地,本实施例的装置还可以包括:第二更新单元18,该第二更新单元18用于若所述第二记录单元17记录获得的所述第一缩减网络流图的缩减次数小于第二预设次数,则将所述第二缩减网络流图更新为所述第一缩减网络流图。Optionally, the apparatus of this embodiment may further include: a second update unit 18, where the second update unit 18 is configured to reduce the number of times of the first reduced network flow graph obtained by the second recording unit 17 to be smaller than And a second preset number of times, updating the second reduced network flow graph to the first reduced network flow graph.
本实施例的装置,可以用于执行本发明上述方法实施例的技术方案,其实现原理和技术效果类似,详细可以参见本发明上述实施例中的相关记载,此处不再赘述。The device in this embodiment may be used to perform the technical solution of the foregoing method embodiment of the present invention. The implementation principle and the technical effect are similar. For details, refer to related descriptions in the foregoing embodiments of the present invention, and details are not described herein again.
图13为本发明网络流图缩减装置实施例四的结构示意图,如图13所示,本实施例的装置包括存储器21和与存储器21连接的处理器22,其中,存储器21中存储一组程序代码,存储器21可以包括非易失性存储器(Non-volatile Memory)。处理器22可以是一个中央处理器(Central  Processing Unit,简称:CPU),或者是特定集成电路(Application Specific Integrated Circuit,简称:ASIC),或者是被配置成实施本发明实施例的一个或多个集成电路。处理器22用于调用存储器21中存储的程序代码,用于执行如下操作:FIG. 13 is a schematic structural diagram of Embodiment 4 of a network flow graph reduction apparatus according to the present invention. As shown in FIG. 13, the apparatus of this embodiment includes a memory 21 and a processor 22 connected to the memory 21, wherein the memory 21 stores a set of programs. The code 21 may include a non-volatile memory. The processor 22 can be a central processor (Central) A processing unit (CPU), or an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The processor 22 is configured to call the program code stored in the memory 21 for performing the following operations:
从待处理网络流图中获取第一网络流子图,所述第一网络流子图包括M个结点和M个结点之间的边,所述M个结点中包括第一端点,所述M为大于或等于2的整数,所述待处理网络流图包括N个结点和N个结点之间的边,所述N个结点中包括源结点和汇结点,所述N为大于M的整数,所述第一端点为源结点或者汇结点,所述源结点为用以表示所述待处理网络流图的网络流的起始结点,所述汇结点为所述网络流的结束结点,其中,各个结点之间的边表示各个结点之间的网络流关系;Acquiring a first network stream sub-picture from the to-be-processed network flow graph, where the first network stream sub-picture includes an edge between the M nodes and the M nodes, where the M nodes include the first end point The M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes an edge between the N nodes and the N nodes, where the N nodes include a source node and a sink node. The N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is a starting node of a network flow used to represent the to-be-processed network flow graph. The summary node is an end node of the network flow, wherein an edge between each node represents a network flow relationship between the nodes;
将所述第一网络流子图合并成一个第一结点;Combining the first network stream submap into a first node;
将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,所述第二网络流子图由所述待处理网络流图中除去所述第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;所述第一网络流子图的所有结点与所述第二网络流子图的所有结点之间的边成为所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图包括所述第一结点、所述第二网络流子图,以及所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第一结点为所述第一缩减网络流图的第一端点。Forming, by the first node, a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow graph, where the second network proxy submap is Determining, in the processing network flow graph, all remaining nodes except the first network stream submap and edge components between the remaining nodes; all nodes and locations of the first network stream submap An edge between all nodes of the second network stream submap becomes an edge between the first node and all nodes of the second network stream submap, and the first reduced network flow graph includes a first node, the second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum of the first reduced network flow graph The cut capacity is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
可选地,所述将所述第一部分待处理网络流图合并成一个第一结点,包括:将所述第一网络流子图的M个结点之间的边去掉;将所述M个结点聚合为一个所述第一结点。Optionally, the merging the first part of the to-be-processed network flow graph into a first node comprises: removing an edge between the M nodes of the first network stream submap; The nodes are aggregated into one of the first nodes.
可选地,所述从待处理网络流图中获取第一网络流子图,包括:Optionally, the obtaining the first network stream submap from the to-be-processed network flow graph includes:
从所述第一端点开始,搜索获取包括预设个数结点的第三网络流子图,所述第三网络流子图包括所述搜索获取的所述预设个数结点和所述搜索获取的所述预设个数结点之间的边,所述预设个数大于或等于所述M;Starting from the first endpoint, searching for a third network stream submap including a preset number of nodes, where the third network stream submap includes the preset number of nodes and locations obtained by the search The search for the edge between the preset number of nodes, the preset number is greater than or equal to the M;
将所述待处理网络流图中除所述第三网络流子图之外的第四网络流子图合并为一个第二结点,所述第四网络流子图由所述待处理网络流图中除去所述第三网络流子图之外的所有剩余结点以及所述除去所述第三网络流 子图之外的所有剩余结点之间的边组成;Merging the fourth network stream submap other than the third network stream submap in the to-be-processed network flow graph into a second node, where the fourth network stream submap is used by the to-be-processed network stream Removing all remaining nodes except the third network stream submap and removing the third network stream The edge between all remaining nodes outside the subgraph;
将所述第二结点与所述第三网络流子图组成第五网络流子图,所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,所述第五网络流子图包括所述第二结点、所述第三网络流子图以及所述第二结点与所述第三网络流子图的所有结点之间的边,所述第二结点为所述第五网络流子图的第二端点;Forming, by the second node and the third network stream submap, a fifth network stream submap, where all nodes of the fourth network stream submap and all nodes of the third network stream submap An edge between the second node and all nodes of the third network stream submap, the fifth network stream submap including the second node, the third network a stream submap and an edge between the second node and all nodes of the third network stream submap, the second node being a second endpoint of the fifth network stream submap;
其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;Wherein, when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node;
根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图。And determining, according to the minimum cut partition of the fifth network stream submap, the first minimum cut subgraph of the fifth network stream submap as the first network stream submap.
可选地,所述根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图之后,还包括:Optionally, after the first minimum cut sub-picture of the fifth network stream sub-picture is used as the first network stream sub-picture according to the minimum cut partition of the fifth network stream sub-map, the method further includes:
将所述第二结点还原为所述第四网络流子图,所述第二结点与所述第三网络流子图的所有结点之间的边成为所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边。Restoring the second node to the fourth network stream submap, and the edge between the second node and all nodes of the third network stream submap becomes the fourth network stream submap The edge between all nodes and all nodes of the third network stream submap.
可选地,所述将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图之后,还包括:将所述待处理网络流图的缩减次数进行记录,获得所述待处理网络流图的缩减次数。Optionally, after the first node and the second network stream submap other than the first network stream submap in the to-be-processed network flow graph are formed into the first reduced network flow graph, the method further includes: Recording the reduced number of times of the to-be-processed network flow graph to obtain a reduced number of times of the to-be-processed network flow graph.
可选地,若所述待处理网络流图的缩减次数小于第一预设次数,则将所述第一缩减网络流图更新为所述待处理网络流图。Optionally, if the number of times of reduction of the to-be-processed network flow graph is less than the first preset number of times, updating the first reduced network flow graph to the to-be-processed network flow graph.
可选地,若所述待处理网络流图的缩减次数不小于所述第一预设次数,则所述方法还包括:Optionally, if the number of times of the network flow graph to be processed is not less than the first preset number of times, the method further includes:
从所述第一缩减网络流图中获取第六网络流子图,所述第六网络流子图包括K个结点和K个结点之间的边,所述K为大于或等于2的整数,所述K个结点中包括第二端点,其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;Obtaining a sixth network stream submap from the first reduced network flow graph, where the sixth network stream submap includes edges between K nodes and K nodes, where K is greater than or equal to 2 An integer, wherein the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node The second endpoint is a source node;
将所述第六网络流子图合并成一个第三结点;Combining the sixth network stream submap into a third node;
将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,所述第七网络流子图由所述第一 缩减网络流图中除去所述第六网络流子图之外的所有剩余结点以及所述除去所述第六网络流子图之外的所有剩余结点之间的边组成;所述第六网络流子图的所有结点与所述第七网络流子图的所有结点之间的边,成为所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图包括所述第七网络流子图、所述第三结点、以及所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图的最小割的容量等于所述第一缩减网络流图的最小割的容量,所述第三结点为所述第二缩减网络流图的第二端点。Forming, by the third node, a seventh network stream sub-picture other than the sixth network stream sub-picture in the first reduced network flow graph to form a second reduced network flow graph, where the seventh network flow sub-graph is configured by The first Reducing, in the network flow graph, all remaining nodes except the sixth network stream submap and edge components between the remaining nodes except the sixth network stream submap; An edge between all nodes of the network stream submap and all nodes of the seventh network stream submap becomes an edge between the third node and all nodes of the seventh network stream submap The second reduced network flow graph includes the seventh network stream submap, the third node, and an edge between the third node and all nodes of the seventh network stream submap The minimum cut capacity of the second reduced network flow graph is equal to the minimum cut capacity of the first reduced network flow graph, and the third node is the second endpoint of the second reduced network flow graph.
可选地,所述将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图之后,还包括:将所述第一缩减网络流图的缩减次数进行记录,获得所述第一缩减网络流图的缩减次数。Optionally, after the third node and the seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph form a second reduced network flow graph, the method further includes : recording the reduced number of times of the first reduced network flow graph to obtain a reduced number of times of the first reduced network flow graph.
可选地,若所述第一缩减网络流图的缩减次数小于第二预设次数,则将所述第二缩减网络流图更新为所述第一缩减网络流图。Optionally, if the number of times of reduction of the first reduced network flow graph is less than a second preset number of times, updating the second reduced network flow graph to the first reduced network flow graph.
需要说明的是,处理器22通过调用存储器21中存储的程序代码具体实现的技术方案可以参见本发明网络流图缩减方法的上述实施例,其实现原理和技术效果类似,详细可以参见上述实施例中的相关记载,在此不再赘述。It should be noted that the technical solution that the processor 22 specifically implements by calling the program code stored in the memory 21 can refer to the foregoing embodiment of the network flow graph reduction method of the present invention. The implementation principle and technical effects are similar. For details, refer to the foregoing embodiment. The relevant records in the description are not repeated here.
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。One of ordinary skill in the art will appreciate that all or part of the steps to implement the various method embodiments described above may be accomplished by hardware associated with the program instructions. The aforementioned program can be stored in a computer readable storage medium. The program, when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。 Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will understand that The technical solutions described in the foregoing embodiments may be modified, or some or all of the technical features may be equivalently replaced; and the modifications or substitutions do not deviate from the technical solutions of the embodiments of the present invention. range.

Claims (18)

  1. 一种网络流图缩减方法,其特征在于,包括:A network flow graph reduction method, comprising:
    从待处理网络流图中获取第一网络流子图,所述第一网络流子图包括M个结点和M个结点之间的边,所述M个结点中包括第一端点,所述M为大于或等于2的整数,所述待处理网络流图包括N个结点和N个结点之间的边,所述N个结点中包括源结点和汇结点,所述N为大于M的整数,所述第一端点为源结点或者汇结点,所述源结点为用以表示所述待处理网络流图的网络流的起始结点,所述汇结点为所述网络流的结束结点,其中,各个结点之间的边表示各个结点之间的网络流关系;Acquiring a first network stream sub-picture from the to-be-processed network flow graph, where the first network stream sub-picture includes an edge between the M nodes and the M nodes, where the M nodes include the first end point The M is an integer greater than or equal to 2, and the to-be-processed network flow graph includes an edge between the N nodes and the N nodes, where the N nodes include a source node and a sink node. The N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is a starting node of a network flow used to represent the to-be-processed network flow graph. The summary node is an end node of the network flow, wherein an edge between each node represents a network flow relationship between the nodes;
    将所述第一网络流子图合并成一个第一结点;Combining the first network stream submap into a first node;
    将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,所述第二网络流子图由所述待处理网络流图中除去所述第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;所述第一网络流子图的所有结点与所述第二网络流子图的所有结点之间的边成为所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图包括所述第一结点、所述第二网络流子图,以及所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第一结点为所述第一缩减网络流图的第一端点。Forming, by the first node, a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow graph, where the second network proxy submap is Determining, in the processing network flow graph, all remaining nodes except the first network stream submap and edge components between the remaining nodes; all nodes and locations of the first network stream submap An edge between all nodes of the second network stream submap becomes an edge between the first node and all nodes of the second network stream submap, and the first reduced network flow graph includes a first node, the second network stream submap, and an edge between the first node and all nodes of the second network stream submap, the minimum of the first reduced network flow graph The cut capacity is equal to the minimum cut capacity of the to-be-processed network flow graph, and the first node is the first endpoint of the first reduced network flow graph.
  2. 根据权利要求1所述的方法,所述将所述第一部分待处理网络流图合并成一个第一结点,包括:The method according to claim 1, wherein the merging the first part of the to-be-processed network flow graph into a first node comprises:
    将所述第一网络流子图的M个结点之间的边去掉;Removing the edge between the M nodes of the first network stream submap;
    将所述M个结点聚合为一个所述第一结点。The M nodes are aggregated into one of the first nodes.
  3. 根据权利要求1或2所述的方法,其特征在于,所述从待处理网络流图中获取第一网络流子图,包括:The method according to claim 1 or 2, wherein the obtaining the first network stream submap from the to-be-processed network flow graph comprises:
    从所述第一端点开始,搜索获取包括预设个数结点的第三网络流子图,所述第三网络流子图包括所述搜索获取的所述预设个数结点和所述搜索获取的所述预设个数结点之间的边,所述预设个数大于或等于所述M;Starting from the first endpoint, searching for a third network stream submap including a preset number of nodes, where the third network stream submap includes the preset number of nodes and locations obtained by the search The search for the edge between the preset number of nodes, the preset number is greater than or equal to the M;
    将所述待处理网络流图中除所述第三网络流子图之外的第四网络流子图合并为一个第二结点,所述第四网络流子图由所述待处理网络流图中除 去所述第三网络流子图之外的所有剩余结点以及所述除去所述第三网络流子图之外的所有剩余结点之间的边组成;Merging the fourth network stream submap other than the third network stream submap in the to-be-processed network flow graph into a second node, where the fourth network stream submap is used by the to-be-processed network stream In addition to the figure Determining an edge between all remaining nodes except the third network stream submap and all remaining nodes except the third network stream submap;
    将所述第二结点与所述第三网络流子图组成第五网络流子图,所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,所述第五网络流子图包括所述第二结点、所述第三网络流子图以及所述第二结点与所述第三网络流子图的所有结点之间的边,所述第二结点为所述第五网络流子图的第二端点;Forming, by the second node and the third network stream submap, a fifth network stream submap, where all nodes of the fourth network stream submap and all nodes of the third network stream submap An edge between the second node and all nodes of the third network stream submap, the fifth network stream submap including the second node, the third network a stream submap and an edge between the second node and all nodes of the third network stream submap, the second node being a second endpoint of the fifth network stream submap;
    其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;Wherein, when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node;
    根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图。And determining, according to the minimum cut partition of the fifth network stream submap, the first minimum cut subgraph of the fifth network stream submap as the first network stream submap.
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图之后,还包括:The method according to claim 3, wherein the first minimum cut subgraph of the fifth network stream submap is used as the first according to a minimum cut partition of the fifth network stream submap After the network stream submap, it also includes:
    将所述第二结点还原为所述第四网络流子图,所述第二结点与所述第三网络流子图的所有结点之间的边成为所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边。Restoring the second node to the fourth network stream submap, and the edge between the second node and all nodes of the third network stream submap becomes the fourth network stream submap The edge between all nodes and all nodes of the third network stream submap.
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图之后,还包括:The method according to any one of claims 1 to 4, wherein the first node and the second network stream except the first network stream submap in the to-be-processed network flow graph After the subgraph constitutes the first reduced network flow graph, it also includes:
    将所述待处理网络流图的缩减次数进行记录,获得所述待处理网络流图的缩减次数。Recording the reduced number of times of the to-be-processed network flow graph to obtain a reduced number of times of the to-be-processed network flow graph.
  6. 根据权利要求5所述的方法,其特征在于,若所述待处理网络流图的缩减次数小于第一预设次数,则将所述第一缩减网络流图更新为所述待处理网络流图。The method according to claim 5, wherein if the number of times of reduction of the to-be-processed network flow graph is less than a first preset number of times, updating the first reduced network flow graph to the to-be-processed network flow graph .
  7. 根据权利要求6所述的方法,其特征在于,若所述待处理网络流图的缩减次数不小于所述第一预设次数,则所述方法还包括:The method according to claim 6, wherein the method further comprises: if the number of times of the network flow graph to be processed is not less than the first predetermined number of times, the method further comprises:
    从所述第一缩减网络流图中获取第六网络流子图,所述第六网络流子图包括K个结点和K个结点之间的边,所述K为大于或等于2的整数,所述K个结点中包括第二端点,其中,当所述第一端点为源结点时,所述第 二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;Obtaining a sixth network stream submap from the first reduced network flow graph, where the sixth network stream submap includes edges between K nodes and K nodes, where K is greater than or equal to 2 An integer, wherein the K nodes include a second endpoint, wherein when the first endpoint is a source node, the The second endpoint is a sink node, and when the first endpoint is a sink node, the second endpoint is a source node;
    将所述第六网络流子图合并成一个第三结点;Combining the sixth network stream submap into a third node;
    将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,所述第七网络流子图由所述第一缩减网络流图中除去所述第六网络流子图之外的所有剩余结点以及所述除去所述第六网络流子图之外的所有剩余结点之间的边组成;所述第六网络流子图的所有结点与所述第七网络流子图的所有结点之间的边,成为所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图包括所述第七网络流子图、所述第三结点、以及所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图的最小割的容量等于所述第一缩减网络流图的最小割的容量,所述第三结点为所述第二缩减网络流图的第二端点。Forming, by the third node, a seventh network stream sub-picture other than the sixth network stream sub-picture in the first reduced network flow graph to form a second reduced network flow graph, where the seventh network flow sub-graph is configured by Removing, in the first reduced network flow diagram, all remaining nodes except the sixth network stream submap and edge components between the remaining nodes except the sixth network stream submap; An edge between all nodes of the sixth network stream submap and all nodes of the seventh network stream submap becomes all nodes of the third node and the seventh network stream submap The second reduced network flow graph includes the seventh network stream submap, the third node, and all nodes of the third node and the seventh network stream submap Between the edges, the minimum cut capacity of the second reduced network flow graph is equal to the minimum cut capacity of the first reduced network flow graph, and the third node is the second reduced network flow graph Two endpoints.
  8. 根据权利要求7所述的方法,其特征在于,所述将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图之后,还包括:The method according to claim 7, wherein the third node and the seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph are combined After reducing the network flow graph, it also includes:
    将所述第一缩减网络流图的缩减次数进行记录,获得所述第一缩减网络流图的缩减次数。Recording the number of reductions of the first reduced network flow graph to obtain a reduced number of times of the first reduced network flow graph.
  9. 根据权利要求8所述的方法,其特征在于,若所述第一缩减网络流图的缩减次数小于第二预设次数,则将所述第二缩减网络流图更新为所述第一缩减网络流图。The method according to claim 8, wherein the second reduced network flow graph is updated to the first reduced network if the number of reductions of the first reduced network flow graph is less than a second predetermined number of times Flow chart.
  10. 一种网络流图缩减装置,其特征在于,包括:A network flow graph reduction device, comprising:
    获取单元,用于从待处理网络流图中获取第一网络流子图,所述第一网络流子图包括M个结点和M个结点之间的边,所述M个结点中包括第一端点,所述M为大于或等于2的整数,所述待处理网络流图包括N个结点和N个结点之间的边,所述N个结点中包括源结点和汇结点,所述N为大于M的整数,所述第一端点为源结点或者汇结点,所述源结点为用以表示所述待处理网络流图的网络流的起始结点,所述汇结点为所述网络流的结束结点,其中,各个结点之间的边表示各个结点之间的网络流关系;An acquiring unit, configured to obtain a first network stream sub-picture from a to-be-processed network flow graph, where the first network stream sub-picture includes an edge between the M nodes and the M nodes, where the M nodes are Including a first endpoint, the M is an integer greater than or equal to 2, the to-be-processed network flow graph includes edges between N nodes and N nodes, and the N nodes include source nodes And a sink node, where N is an integer greater than M, the first endpoint is a source node or a sink node, and the source node is a network flow used to represent the to-be-processed network flow graph a start node, where the sink node is an end node of the network flow, wherein an edge between each node represents a network flow relationship between the nodes;
    合并单元,用于将所述获取单元获取的第一网络流子图合并成一个第一结点;a merging unit, configured to merge the first network stream sub-graph obtained by the acquiring unit into a first node;
    处理单元,用于将所述合并单元合并获得的所述第一结点与所述待处 理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图,所述第二网络流子图由所述待处理网络流图中除去所述第一网络流子图之外的所有剩余结点以及所述所有剩余结点之间的边组成;所述第一网络流子图的所有结点与所述第二网络流子图的所有结点之间的边成为所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图包括所述第一结点、所述第二网络流子图,以及所述第一结点与所述第二网络流子图的所有结点之间的边,所述第一缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第一结点为所述第一缩减网络流图的第一端点。a processing unit, configured to merge the merged unit to obtain the first node and the to-be-before The second network stream submap in addition to the first network stream submap in the network flow graph constitutes a first reduced network flow graph, and the second network stream submap is removed from the to-be-processed network flow graph All remaining nodes except a network stream sub-picture and edges between the remaining nodes; all nodes of the first network stream sub-picture and all nodes of the second network stream sub-picture An edge between the first node and all nodes of the second network stream submap, the first reduced network flow graph including the first node, the second network a stream map, and an edge between the first node and all nodes of the second network stream submap, the minimum cut capacity of the first reduced network flow graph is equal to the to-be-processed network flow graph The minimum cut capacity, the first node being the first endpoint of the first reduced network flow graph.
  11. 根据权利要求10所述的装置,其特征在于,所述合并单元具体用于将所述第一网络流子图的M个结点之间的边去掉,并将所述M个结点聚合为一个所述第一结点。The apparatus according to claim 10, wherein the merging unit is specifically configured to remove an edge between the M nodes of the first network stream submap and aggregate the M nodes into One of the first nodes.
  12. 根据权利要求10或11所述的装置,其特征在于,所述获取单元具体用于从所述第一端点开始,搜索获取包括预设个数结点的第三网络流子图,所述第三网络流子图包括所述搜索获取的所述预设个数结点和所述搜索获取的所述预设个数结点之间的边,所述预设个数大于或等于所述M;将所述待处理网络流图中除所述第三网络流子图之外的第四网络流子图合并为一个第二结点,所述第四网络流子图由所述待处理网络流图中除去所述第三网络流子图之外的所有剩余结点以及所述除去所述第三网络流子图之外的所有剩余结点之间的边组成;并将所述第二结点与所述第三网络流子图组成第五网络流子图,所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边,成为所述第二结点与所述第三网络流子图的所有结点之间的边,所述第五网络流子图包括所述第二结点、所述第三网络流子图以及所述第二结点与所述第三网络流子图的所有结点之间的边,所述第二结点为所述第五网络流子图的第二端点;其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图。The apparatus according to claim 10 or 11, wherein the obtaining unit is specifically configured to: start from the first endpoint, search for a third network stream submap including a preset number of nodes, The third network stream submap includes an edge between the preset number of nodes acquired by the search and the preset number of nodes acquired by the search, where the preset number is greater than or equal to the edge Merging a fourth network stream submap other than the third network stream submap in the to-be-processed network flow graph into a second node, where the fourth network stream submap is to be processed Removing, in the network flow graph, all remaining nodes except the third network stream submap and edge components between the remaining nodes except the third network stream submap; and The second node and the third network stream submap constitute a fifth network stream submap, and an edge between all nodes of the fourth network stream submap and all nodes of the third network stream submap, An edge between the second node and all nodes of the third network stream submap, the fifth network stream Include the second node, the third network stream submap, and an edge between the second node and all nodes of the third network stream submap, the second node being the a second endpoint of the fifth network flow submap; wherein, when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node, The second endpoint is a source node; according to the minimum cut partition of the fifth network stream submap, the first minimum cut subgraph of the fifth network stream submap is used as the first network stream submap.
  13. 根据权利要求12所述的装置,其特征在于,还包括:The device according to claim 12, further comprising:
    还原单元,用于所述获取单元根据所述第五网络流子图的最小割划分,将所述第五网络流子图的第一最小割子图作为所述第一网络流子图之后, 将所述第二结点还原为所述第四网络流子图,所述第二结点与所述第三网络流子图的所有结点之间的边成为所述第四网络流子图的所有结点与所述第三网络流子图的所有结点之间的边。a restoring unit, configured to: after the obtaining, the first minimum cut sub-graph of the fifth network stream submap as the first network stream submap according to the minimum cut partition of the fifth network stream submap Restoring the second node to the fourth network stream submap, and the edge between the second node and all nodes of the third network stream submap becomes the fourth network stream submap The edge between all nodes and all nodes of the third network stream submap.
  14. 根据权利要求10-13任一项所述的装置,其特征在于,还包括:The device according to any one of claims 10-13, further comprising:
    第一记录单元,用于所述处理单元将所述第一结点与所述待处理网络流图中除第一网络流子图之外的第二网络流子图组成第一缩减网络流图之后,将所述待处理网络流图的缩减次数进行记录,获得所述待处理网络流图的缩减次数。a first recording unit, configured by the processing unit to form, by the first node, a second network stream submap other than the first network stream submap in the to-be-processed network flow graph to form a first reduced network flow graph Then, the number of times of reduction of the to-be-processed network flow graph is recorded, and the number of times of reduction of the to-be-processed network flow graph is obtained.
  15. 根据权利要求14所述的装置,其特征在于,还包括:The device according to claim 14, further comprising:
    第一更新单元,用于若所述第一记录单元记录获得的所述待处理网络流图的缩减次数小于第一预设次数,则将所述第一缩减网络流图更新为所述待处理网络流图。a first updating unit, configured to update the first reduced network flow graph to the to-be-processed if the number of times of reduction of the to-be-processed network flow graph obtained by the first recording unit is less than a first preset number of times Network flow diagram.
  16. 根据权利要求15所述的装置,其特征在于,若所述第一记录单元记录获得的所述待处理网络流图的缩减次数不小于第一预设次数,则所述获取单元,还用于从所述第一缩减网络流图中获取第六网络流子图,所述第六网络流子图包括K个结点和K个结点之间的边,所述K为大于或等于2的整数,所述K个结点中包括第二端点,其中,当所述第一端点为源结点时,所述第二端点为汇结点,当所述第一端点为汇结点时,所述第二端点为源结点;The apparatus according to claim 15, wherein the obtaining unit is further used if the number of times of reduction of the to-be-processed network flow graph obtained by the first recording unit is not less than a first preset number of times Obtaining a sixth network stream submap from the first reduced network flow graph, where the sixth network stream submap includes edges between K nodes and K nodes, where K is greater than or equal to 2 An integer, wherein the K nodes include a second endpoint, wherein when the first endpoint is a source node, the second endpoint is a sink node, and when the first endpoint is a sink node The second endpoint is a source node;
    所述合并单元,还用于将所述获取单元获取的所述第六网络流子图合并成一个第三结点;The merging unit is further configured to merge the sixth network stream submap obtained by the acquiring unit into a third node;
    所述处理单元,还用于将所述合并单元合并获得的所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图,所述第七网络流子图由所述第一缩减网络流图中除去所述第六网络流子图之外的所有剩余结点以及所述除去所述第六网络流子图之外的所有剩余结点之间的边组成;所述第六网络流子图的所有结点与所述第七网络流子图的所有结点之间的边,成为所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图包括所述第七网络流子图、所述第三结点、以及所述第三结点与所述第七网络流子图的所有结点之间的边,所述第二缩减网络流图的最小割的容量等于所述待处理网络流图的最小割的容量,所述第三结点为所述第二缩减网络流图的第二端点。 The processing unit is further configured to combine the third node obtained by combining the merging unit with a seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph. Diluting a network flow graph, wherein the seventh network stream submap removes all remaining nodes except the sixth network stream submap from the first reduced network flow graph and the removing the sixth network stream a side between all remaining nodes except the sub-picture; the edge between all the nodes of the sixth network stream sub-picture and all the nodes of the seventh network stream sub-picture becomes the third An edge between the node and all nodes of the seventh network stream submap, the second reduced network flow graph including the seventh network stream submap, the third node, and the third An edge between the node and all nodes of the seventh network stream submap, and a minimum cut capacity of the second reduced network flow graph is equal to a minimum cut capacity of the to-be-processed network flow graph, the first The third node is the second endpoint of the second reduced network flow graph.
  17. 根据权利要求16所述的装置,其特征在于,还包括:The device according to claim 16, further comprising:
    第二记录单元,用于所述处理单元将所述第三结点与所述第一缩减网络流图中除第六网络流子图之外的第七网络流子图组成第二缩减网络流图之后,将所述第一缩减网络流图的缩减次数进行记录,获得所述第一缩减网络流图的缩减次数。a second recording unit, configured by the processing unit to form the third node and the seventh network stream submap other than the sixth network stream submap in the first reduced network flow graph to form a second reduced network stream After the figure, the number of reductions of the first reduced network flow graph is recorded, and the number of reductions of the first reduced network flow graph is obtained.
  18. 根据权利要求17所述的装置,其特征在于,还包括:The device according to claim 17, further comprising:
    第二更新单元,用于若所述第二记录单元记录获得的所述第一缩减网络流图的缩减次数小于第二预设次数,则将所述第二缩减网络流图更新为所述第一缩减网络流图。 a second updating unit, configured to update the second reduced network flow graph to the first if the number of times of reduction of the first reduced network flow graph obtained by the second recording unit record is less than a second preset number of times A reduced network flow graph.
PCT/CN2014/086482 2013-09-29 2014-09-15 Method and apparatus for reducing network flow graph WO2015043385A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310456975.0 2013-09-29
CN201310456975.0A CN104516995A (en) 2013-09-29 2013-09-29 Network-flow graph reduction method and device

Publications (1)

Publication Number Publication Date
WO2015043385A1 true WO2015043385A1 (en) 2015-04-02

Family

ID=52742023

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/086482 WO2015043385A1 (en) 2013-09-29 2014-09-15 Method and apparatus for reducing network flow graph

Country Status (2)

Country Link
CN (1) CN104516995A (en)
WO (1) WO2015043385A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108683599A (en) * 2018-05-15 2018-10-19 河南工业大学 One kind determining method and system based on pretreated distribution network max-flow

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108900320B (en) * 2018-06-04 2021-02-09 佛山科学技术学院 Method and device for reducing topological structure of Internet test bed in large scale

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080222614A1 (en) * 2007-03-05 2008-09-11 Microsoft Corporation Preferential path profiling
CN101833553A (en) * 2009-03-09 2010-09-15 夏普株式会社 Method, equipment and system for clustering data
US20130024479A1 (en) * 2011-07-20 2013-01-24 Salesforce.Com, Inc. Methods and systems for processing large graphs using density-based processes using map-reduce
US20130132442A1 (en) * 2011-11-21 2013-05-23 Motorola Mobility, Inc. Ontology construction
CN103189836A (en) * 2010-08-30 2013-07-03 国际商业机器公司 Method for classification of objects in a graph data stream

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080222614A1 (en) * 2007-03-05 2008-09-11 Microsoft Corporation Preferential path profiling
CN101833553A (en) * 2009-03-09 2010-09-15 夏普株式会社 Method, equipment and system for clustering data
CN103189836A (en) * 2010-08-30 2013-07-03 国际商业机器公司 Method for classification of objects in a graph data stream
US20130024479A1 (en) * 2011-07-20 2013-01-24 Salesforce.Com, Inc. Methods and systems for processing large graphs using density-based processes using map-reduce
US20130132442A1 (en) * 2011-11-21 2013-05-23 Motorola Mobility, Inc. Ontology construction

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108683599A (en) * 2018-05-15 2018-10-19 河南工业大学 One kind determining method and system based on pretreated distribution network max-flow
CN108683599B (en) * 2018-05-15 2021-09-07 河南工业大学 Preprocessing-based method and system for determining maximum flow of flow network

Also Published As

Publication number Publication date
CN104516995A (en) 2015-04-15

Similar Documents

Publication Publication Date Title
US9253077B2 (en) Parallel top-K simple shortest paths discovery
US9798774B1 (en) Graph data search method and apparatus
Ajwani et al. FOARS: FLUTE based obstacle-avoiding rectilinear Steiner tree construction
Cator et al. Susceptible-infected-susceptible epidemics on networks with general infection and cure times
WO2014107988A1 (en) Method and system for discovering and analyzing micro-blog user group structure
Badia et al. On monotonicity-preserving stabilized finite element approximations of transport problems
JP2011007713A (en) Multi-pairs shortest path finding method and system
TWI652586B (en) Group search method and device based on social network
CN107689628B (en) Power grid loop detection method
CN108255987A (en) Community-based node betweenness center degree update method
WO2015043385A1 (en) Method and apparatus for reducing network flow graph
WO2023030094A1 (en) Matrix operation-based mobile social network graph modification method
Pu et al. Iterative path attacks on networks
Sioutis et al. Efficiently characterizing non-redundant constraints in large real world qualitative spatial networks
JP2015156529A (en) Flow aggregation device, method and program
WO2021027745A1 (en) Graph reconstruction method and apparatus
CN109412149B (en) Power grid subgraph construction method based on regional division, topology analysis method and device
Liu et al. Complex network node centrality measurement based on multiple attributes
CN113421316B (en) Connection line path construction method and device, computer equipment and readable storage medium
CN108768735B (en) Bipartite graph sampling method and device for test bed topological structure
JP6597143B2 (en) Display processing method, display processing program, and display processing apparatus
Hou et al. Expanded Koch networks: structure and trapping time of random walks
Chu et al. On estimating the spectral radius of large graphs through subgraph sampling
CN111127230A (en) Dynamic social circle determination method, device, equipment and storage medium
Guo et al. A Topology‐Inferred Graph‐Based Heuristic Algorithm for Map Simplification

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: 14847664

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: 14847664

Country of ref document: EP

Kind code of ref document: A1