Realization of Metro transfer map by using single source shortest path algorithm with no graph

Source: Internet
Author: User

Metro.php$metrovertex = Array (1 = ' Sports Center ', 2 = ' Sports West road ', 3 = ' Yang Ji ', 4 = ' East Yamaguchi ', 5 = ' Martyrs ' Cemetery ', 6 = ' Nong Talk ', 7 = ' Park front ', 8 = ' West Gate ', 9 = ' Chen Jia ci ', ten ' Changshoulu ', one by one ' yellow sand ', =&gt ;  ' Fangcun ', ' Huadiwan ', + ' Hang Hau ', ' Xilang ', ' Jiahe Wang ', ' Golden Harvest ', ' Yellow edge ', ' Jiangxia ', 19 = ' Xiao Gang ', "Bai Yun Culture Square", "Bai Yun Park", "Flying Park", "three Yuan Li", the "Guangzhou railway Station", 25 = > ' Yuexiu Park ', ' the ' Memorial Hall ', ' Haizhu square ', ' two ' of the city ', ' and ' Jiang Nan Xi ', ' Chang Gang ', * + ' Jiang Thai Road ', [+] ' Dongxiaonan ', "The South state '," "and" ' Luo XI ', "*", "Nanpu", the "will Jiang", Panax Notoginseng "Shek Pik", 38 =& Gt    ' Guangzhou South railway station ', "the" Tianhe Bus Terminal, "Five Mountain", "the" "Hua Division", "the top of the gang", "The" Stone Bridge, "and" The "Pearl River New Town," * "Guangzhou Tower", "a", "The Village of", "the" Big Pond "," and "Lek Kau", "and" "Xia Kau," and "Big Stone", Wuyi " Han Creek Chimelong ', ' City Bridge ', ' the ' Panyu Square ', and the ' airport South ', the ' People and ', "" and "," "and" the "Long", the "" Baiyun Road North, "and" Yongtai ", "With and", "The Beijing Creek South Hospital," "Mei Hua Yuan", "and" "Yan Tong," and "Guangzhou East", "Lin and West ', 65 =& Gt    ' Huang Cun ', ' The ' Che Pei ', "the" Car Po "," the "Che Pei-nan," and "Wan Sheng Wai," "The" Official Chau, "the" University of North, "and" University City South, " The ' new ', the ' Neo ', the ' Acer ', ' The ' sea-pong ', ' the ' low surge ', ' the ' Tung Chung ', the ' Huangge Auto City ' Huangge ', "the" "Banana Door," and "Jinzhou '," Bayi = ' Kau Kou ', "the", "the" "Tan", the "Sun", "Zhongshan Eight", 85 =& Gt ' West Village ', "The small North '," and "Gold", "Jin", "The District Zhuang", "the" Zoo "," "Five Sheep", "Wu Yang Estate", the "Hunting de", 92    = ' Tam village ', "the member village", "94", "Ke Yun Road," "and" "East Nursery", "The Three Rivers", "the" "Fish Bead", 98 "and" Big sand, "Big Sand East", "101", "Xun Feng Gang", 102 = ' Heng Sha ', 103 = ' Sha bei ', 104 = ' river sand ', 106    = ' Ruyi square ',108 = ' Culture Park ', 109 = ' Yi de lu ', 111 = ' Beijing Road ', the "group of a large square," 113 = ' East Lake ', the "Huanghuagang", The ' Shahe top ', 117 = ' Shahe ', 118 = ' balance frame ', 119 = ' long ban ', "The Phoenix Village", "121", "Sha Yuan", 122  = ' po Gang Avenue ', 123 = ' Xiao Port ', 124 = ' In the big ', "126", "Lujiang", "127" and "Red Hillock", the "mill", "Mo" ' Newport East ', 129 = ' Pazhou ', ' the ' Sports Center South ', 131 = ' Days of Henan ', ' the ' Huangpu Avenue ', 133 = ' Women's Center ', 134 =&gt ; ' Huacheng Avenue ', 135 = ' Grand Theatre ', 136 = ' sea Heart Sand '); $Line = Array (); $Line [' 64 '] [' 1 '] = 1; $Line [' '] [' 63 '] = 1; $Line '] = 1; $Line [' 1 '] [' n '] = 1; $Line [' 1 '] [' 2 '] = 1; $Line [' 2 '] [' 1 '] = 1; $Line [' 2 '] [' 1 '] = 2; $Line [' '] [' 3 '] = 1; $Line "2 4 '] = 1; $Line [' 3 '] [' 2 '] = 1; $Line [' 3 '] [' 2 '] = 1; $Line [' 3 '] [' "] = 1; $Line [' 3 '] [' 4 '] = 1; $Line [' 4 '] [' 3 '] = 1; $Line [' 4 '] [' 5 '] = 1; $Line [' 4 '] [' 113 '] = 1; $Line [' 4 '] [' n '] = 1; $Line [' 5 '] [' 4 '] = 1; $Line [' 5 '] [' 6 '] = 1; $Line [' 6 '] [5] = 1; $Line [' 6 '] 7 '] = 1; $Line [' 7 '] [' 8 '] = 1; $Line [' 7 '] [' 6 '] = 1; $Line [' 7 '] ['] = 1; $Line [' 7 '] ['] = 1; $Line [' 8 '] [' 7 '] = 1; $Line [' 8 '] [' 9 '] = 1; $Line [' 9 '] ' 8 ' ] = 1; $Line [' 9 '] ['] = 1; $Line ['] [' 9 '] = 1; $Line ['] ['] ['] = 1; $Line [' One '] [' 108 '] = 1; $Line [' One '] [' 106 '] = 1; $Line [ ' One ' ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line [' 14 '] [' 13 ' ] = 1; $Line ['] ['] ['] = 1; $Line [' + '] [' + '] = 1; $Line ['] ['] ['] '] = 1; $Line [' + '] ['] = 1; $Line ['] ['] [' + '] = 1; $Line [ ' + ' ['] = 1; $Line ['] ['] ['] = 1; $Line [' + '] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line [' 20 '] [' 19 ' ] = 1; $Line [' + '] ['] = 1; $Line [' + '] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ' ['] '] = 1; $Line [ ' ['] [']] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] '] = 1; $Line [' 24 '] [' 86 ' ] = 1; $Line ['] ['] ['] ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] ['] = 1; $Line ['] ['] ' ['] = 1; $Line ['] ['] '] ' + ' ['] = 1; $Line [' 27 '] [' 1['] = 1; $Line ['] ['] [' 111 '] = 1; $Line [' + '] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] [] = 1; $Line ['] ['] ['] = 1; $L Ine[' ['] ['] = 1; $Line ['] ['] = 1; $Line ['] [' 122 '] = 1; $Line ['] ['] [' 123 '] = 1; $Line ['] ['] ['] '] = 1; $Line [' 31 ' [' 1 '] = 1; $Line ['] ['] ['] = 1; $Line [' + '] ['] = 1; $Line ['] ['] ' ['] ['] ['] ['] = 1; $Line ['] ['] [']] = 34; $Line [' '] ' 35 ' $Line ['] ['] ['] [']] = 1; $Line ['] ['] ' ['] '] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] '] = ['] [']] = 1; $Line [' PNs '] ['] ['] = 1; $Line ['] ['] ['] ['] [' 119 '] = 1; $Line ['] ['] '] = 1; $Line ['] ['] [']] = 1; $Line [' 40 '] [' $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ' ['] "[']] = 1; $Line ['] ['] [' 2 '] = 1; $Line ['] ['] ['] [' 2 '] = 1; $Line ['] ['] ['] ['] ['] [']] = 1; $Line ['] ['] [']] = 1 ; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' + '] = 1; $Line [' 46 '] [' 125 '] = 1; $Line [' 126 '] = 1; $Line [' + '] [' 1 '] = 1; $Line [' + '] ['] = 1; $Line ['] ['] ' ['] ['] ['] ['] ['] ['] '] = 1; $Line [' ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] '] = 1; $Line [' N '] ['] = 1; $Line [' 51 '] [' 52 '] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [ "['] [']] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [']] = = 1; $Line ['] ['] ['] ['] ' ['] ['] ' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' "[' + '] = 1; $Line ['] ['] ['] '] = 1; $Line ['] ['] ['] '] = 1; $Line ['] ['] [' 118 '] = 1; $Line ['"] ['] [']] = 1; $Line [' 64 '] [' 63 ' ] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' 2 '] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ' 1 ' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' ] = 1; $Line [' 129 '] ['] = 1; $LinE[' ['] [']] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] ['] = 1; $Line ['] ['] ['] = 1; $Line ['] ['] ['] ' = 1; $Line [' 71 '] [' ['] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [ ne[' 1 ' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [ [' 1 '] = 1; $Line [' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] Ne[' ['] ['] = 1; $Line ['] ['] ['] = 1; $Line [' Bayi ' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] '] = 1; $Line ['] ['] ['] ['] 104 '] = 1; $Line [' ['] ['] [' 106 '] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' Line[' ['] [' + '] = 1; $Line ['] ['] ['] = 1; $Line [' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] = 1; $Line [' [' n '] = 1; $Line [' "] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' 1 '] = ' 4 '] = 1; $Line [' line['] [' 3 '] = 1; $Line [' 90 '] ['3 '] = 1; $Line [' N '] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] [' e[' "['] ['] ['] [']] = 1; $Line ['"] [' 94 '] = 1; $Line [' 94 '] ['] ['] = 1; $Line [' 94 '] [' "] = 1; $Line ['] ['] ['] [']] = 1; $Line ['] = 1; $Line ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] '] = 1; $Line ['] ['] ['] ['] '] = 1; $Line [' 98 '] ['] ['] = 1; $Line [ ne[' 98 ' [' a '] = 1; $Line [' ['] ['] [' 98 '] = 1; $Line [' ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] ['] = 1; $Line [' 102 ' [' 101 '] = 1; $Line [' 102 '] [' 103 '] = 1; $Line [' 103 '] [' 102 '] = 1; $Line [' 103 '] [' 104 '] = 1; $Line [' 104 '] [' 103 '] = 1; $Line [' 104 ' ['] [']] = 1; $Line [' 106 '] [' +] = 1; $Line [' 106 '] ['] = 1; $Line [' 108 '] [' one '] = 1; $Line [' 108 '] [' 109 '] = 1; $Line [' 109 ' [' 108 '] = 1; $Line [' 109 '] [' 111 '] = 1; $Line [' 111 '] = 1; $Line [' 111 '] [' '] = 1; $Line ['] ' ['] '] [' '] = 1; $Line [' 112 '] [ ' 113 '] = 1; $Line [' 113 '] [' 4 '] = 1; $Line [' ['] ['] ['] ['] '] = 1; $Line ['] ['] ['] ' ['] ' ['] ' ['] ' ['] ' ['] ' ['] '] = 1; 117 '] = 1; $Line [' 117 '] [' n '] = 1; $Line ['117 ' [' 118 '] = 1; $Line [' 118 '] [' 117 '] = 1; $Line [' 118 '] [' 1 '] = 1; $Line [' 119 '] [' 1 '] =; $Line [' + '] [' 121 '] =; $Line [' 121 ' [']] = 1; $Line [' 121 '] [' 122 '] = 1; $Line [' 122 '] [' 121 '] = 1; $Line [' 122 '] ['] = 1; $Line [' 123 '] ['] = 1; $Line [' 123 ' [' 124 '] = 1; $Line [' 124 '] [' 123 '] = 1; $Line [' 124 '] [' [']] = 1; $Line ['] ['] [' 124 '] = 1; $Line ['] ['] ['] '] = 1; $Line [' 126 ' ['] [']] = 1; $Line [' 126 '] [' 127 '] = 1; $Line [' 127 '] [' 126 '] = 1; $Line [' 127 '] [' n '] = 1; $Line [' N '] [' 127 '] = 1; $Line [' ['] [' 129 '] = 1, $Line [' 129 '] [' + '] = 1; $Line [' 129 '] ['] ['] = 1; $Line ['] ['] ' [']] = 1; $Line ['] [']] [' 131 '] = 1; $Line [' 131 ' [']] = 1; $Line [' 131 '] [' 133 '] = 1; $Line [' '] [' 131 '] = 1; $Line [' '] = 1; $Line [' 133 '] [') '] = 1; $Line [' 133 ' [' 134 '] = 1; $Line [' 134 '] [' 133 '] = 1; $Line [' 134 '] [' 135 '] = 1; $Line [' 135 '] [' 134 '] = 1; $Line [' 135 '] [' 136 '] = 1; $Line [' 136 ' [' 135 '] = 1; $Line [' 136 '] [' 45 '] = 1;

<?phprequire_once (DirName (__file__).    ' \metro.php ');//print_r ($Line);//Initialize $dist, $path array foreach ($MetroVertex as $k = = $v) {$dist [$k] =-1; $path [$k] =-1;}    function unweighted ($start, $end, $dist, $path, $Line) {$Queue = array ();    $Queue [] = $start;    $dist [$start] = 0;        while (!empty ($Queue)) {$v = Array_shift ($Queue);        $temp = $Line [(string) $v];                foreach ($temp as $k = + $value) {if ($dist [(int) $k] = =-1) {$dist [(int) $k] = $dist [$v] +1;                $path [(int) $k] = $v;            $Queue [] = $k;                } if ((int) $k = = $end) {$find _arr = array ();                $find = $end;                $find _arr[] = $find;                    while ($find! = $start) {$find = $path [$find];                Array_unshift ($find _arr, $find);                } return $find _arr;            Exit }}}} $find _arr = unweighted (50,87, $dist, $path, $Line); foreach ($find _Arr as $k = $v) {$find _arr[$k] = $MetroVertex [$v];} Echo Implode ('-a ', $find _arr);


Pseudo-code, single source shortest path algorithm for unauthorized graphs

    /* adjacency Table Storage-Single source shortest path algorithm for unauthorized graphs */         * dist[] and path[] all initialized to-1 *    /void unweighted (lgraph Graph, int dist[], int path[], Vert Ex S)    {        Queue Q;        Vertex V;        Ptrtoadjvnode W;                 Q = Createqueue (GRAPH->NV); /* Create an empty queue, maxsize for externally defined constants *        /Dist[s] = 0;/* Initialize source point *        /ADDQ (Q, S);             while (! IsEmpty (q)) {            V = Deleteq (q);            For (W=graph->g[v]. Firstedge; W W=w->next)/* W->ADJV                /if (dist[w->adjv]==-1) {/* If W->ADJV has not been visited for each adjacency point of v */                    dist[w->adjv] = dist[v]+1; /* W->ADJV to S distance update *                    /PATH[W->ADJV] = V;/* Record V on path s to W->ADJV *                    /ADDQ (Q, W->ADJV);                }        } /* While end */    }



Realization of Metro transfer map by using single source shortest path algorithm with no graph

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.