The main idea of the algorithm:
Start form any match.
1.Trying to find a path that could make the match larger by reversing the path.
2.If a path is found, reverse it, then goto 1.
3.Shuffle the nodes(why?), then goto 1 (this step could be executed at most 3 times).
I wonder why this algorithm works?(In fact, it seems work well)
I'm really puzzled. Here is the code: http://www.cnblogs.com/wmzisfoolish/p/5639893.html
Any reply is appreciated :-)
The main idea of the algorithm: Start form any match. 1.Trying to find a path that could make the match larger by reversing the path. 2.If a path is found, reverse it, then goto 1. 3.Shuffle the nodes(why?), then goto 1 (this step could be executed at most 3 times). I wonder why this algorithm works?(In fact, it seems work well) I'm really puzzled. Here is the code: http://www.cnblogs.com/wmzisfoolish/p/5639893.html Any reply is appreciated :-)