Network merge speed improvement by rebuilding match edge method. First version, it may still have some issues but it is better to share so people can report problems.

Change-Id: Ibcf19f3f182553f9af5fc1b32e7af3e5369bd72d