performance optimization, changed to array style structure for graph
data structure. APSP algorithm works a lot better now.