Finally I made it!!
Though it's still under development and requires thorough examination and correction, especially the parts for subpath connection and MIS weighting.