Convert undirected graphs to point-to-double-connected graphs
Definition: Point-double connect refers to a path with at least two points that are not duplicated between any two
There are two kinds of cases, one is connected graph, the other is non-connected graph
① Connectivity Diagram
First, find all the points in the graph-the two connected components, and then indent the branch into a single point, because the inside of the two-connected component is definitely not considered.
It is only necessary to consider the two connected components and the other nodes outside, how to add the edge to form the point-double connected component.
The node 2,3,4,5 constitutes a point-a double connected branch, which we indent to get the following figure
As you can see, the graph after the indentation is a tree (because the rings are shrunk to a point)
Then the problem is converted to, if a tree becomes a point-a double-connected graph.
This special structure of the tree, as long as the leaf node between the edge, then you can make any two points there are two points do not repeat the path.
If there is only one leaf node, then just one edge to the root node.
If there are two leaf nodes, just one edge between the two leaf nodes.
If there are three leaf node a,b,c, then as long as a single edge between A, B, b,c a side can be
So the leaf node has cnt_leaf, so just Add (cnt_leaf+1)/2 side
② Non-connected graphs
For a non-connected graph, each connected component becomes a point-to-double connected component, then the method is the same as above.
Then there is only one problem if you make two points-a double-connected component into one.
Similarly, the point-to-double connected component as a point, then two points to become a point-double connectivity, then just add 2 edges on the line
To turn undirected graphs into edges-double-connected graphs
Definition: There are at least two edges of the path that are not duplicated at any two points.
Also divided into two cases, one is connected graph, a non-connected graph
① Connectivity Diagram
Ditto
② Non-connected graphs
Ditto
Turn a forward graph into a strong connected diagram
Definition: A forward graph with any two points that can reach each other is called a strong connected graph.
① Connectivity Diagram
Similarly, find all the strongly connected components and then indent to a point, then count the number of points (recorded as cntout) for the new graph after the indentation, and the number of points with a degree of 0 (recorded as Cntin)
So the number of edges to add is max (Cntout,cntin)
Why is this?? Because, if a point is in the degree of 0, then the point is not reached, if a point of the degree of 0, then the point to other points is not reached.
To resolve this situation, this is resolved only if a u-->v edge is connected between points with a degree of 0 (set to u) and a point with an entry degree of 0.
Continuous edge, as long as a point problem is not resolved to the edge, so is to take max between the two
② Non-connected graphs
For each connected branch, the above method becomes the strongly connected component.
As for the two connected components, a single side that you point to me, and a side that I point to you.
How to change undirected graph to point/edge double connectivity, how to turn a forward graph into a strong connected graph