180 likes | 341 Views
TSP in line graphs. 2-optimal Euler path problem. v4. v1. v3. v5. v2. v6. Euler circuit in a directed graph:. An Euler circuit in a directed graph is a directed circuit that visits every edge in G exactly once. b. d. e. g. a. c. f. Figure 1. Theorem 2:.
E N D
TSP in line graphs 2-optimal Euler path problem
v4 v1 v3 v5 v2 v6 Euler circuit in a directed graph: • An Euler circuit in a directed graph is a directed circuit that visits every edge in G exactly once. b d e g a c f Figure 1
Theorem 2: • If all the vertices of a connected graph have equal in-degrees and out-degrees, then the graph has an Euler circuit.
2-path: • A 2-path is a directed subgraph consisting of two consecutive edges. For example: • v is called the midpoint. • Every 2-path is given a cost (positive number) • A Euler circuit of m edges contains m 2-paths,and the cost of the Euler circuit is the total weight of the m 2-paths. u v w
2-optimal Euler circuit problem: • Instance: A directed graph, each of its vertices has in-degree 2 and out-degree 2 and 2-path has a cost. • Question:Find an Euler circuit with the smallest cost among all possible Euler circuits.
Line graph: • If we view each edge in the above graph G(Figure 1) as a vertex,and each 2-path in the above graph as an edge,we get another graph L(G), called line graph. d b e a c g f Figure 2
Continue: • Observation: An Euler circuit in graph G corresponds to a Hamilton circuit in graph L(G). • 2-optimal Euler path problem becomes a TSP problem in line graph.
Theorem 3: • TSP in line graph with in-degree 2 and out-degree 2 can be solved in polynomial time. (TSP in general is NP-complete)
Facts: • For each node in G,there are four 2-paths that form 2 pairs of 2-paths. • In an Euler circuit,one of the pairs is used. • A pair of 2-path for v is good if the total cost of this pair of 2-paths is not less than that of the other pair.
Algorithm: • For each node v in G, fixed the good pair of 2-path for v. (This leads to a set of edge disjoint circles H.) • Contract each circle Ci in H into a single node ni .There is an edge(undirected) between ni and nj if Ci and Cj have a common vertex,say,v. The weight on edge (ni,nj) is w(e1)+w(e2)-w(e3)-w(e4) where e1 and e2 forms a bad pair for v,and e3 and e4 forms a good pair for v.Call H’ be the resulting undirected graph. • Construct a minimum spanning tree H’ • Construct an Euler circuit for G by merging circles based on the minimum spanning tree obtained in Step3.
Example: • Suppose that the directed Euler graph G is Given in Figure 3(next page).There are 5 cycles.The 2-paths in circles have cost 1 and the costs on other 2-paths are listed below: w(a,e)=2,w(h,b)=2; w(f,i)=3,w(l,g)=3; w(g,t)=2,w(s,h)=11; w(k,m)=1,w(p,l)=2; w(t,o)=2,w(n,q)=3.
j f i k e l a d m p g b h c o t n s r q Figure 3
j f i k e l a d m p g b h c o t n s r q Step1:we get 5 circles shown below:
Step2:the undirected graph constructed is: e,f,g,h 4 i,j,k,l 2 1 11 a,b,c,d 3 m,n,o,p q,r,s,t
Step3:the minimum spanning tree for the above tree is as follows: 4 2 1 3
j f i k e l a d m p g b h c o t n s r q Step4:The 2-optimal Euler path is shown below:
Theorem 4: • The above algorithm is correct. • Proof: • The total cost of the 2-paths obtained in Step1 is not greater than that of the optimal solution. • To obtain an Euler circuit, we have to merge the k circles obtained in Step1.(needs (k-1) merge operations) • These (k-1) merge operations correspond to (k-1) edges in the undirected graph.(In fact, a spanning tree) • The final cost is the cost of all the 2-paths obtained in Step1 + the cost of the (minimum) spanning tree. • Since we use a minimum spanning tree, the cost of our solution is the smallest.