1234567891011121314151617181920212223242526272829303132333435 |
package mainimport ("fmt""github.com/looplab/tarjan")func main() {graph := make(map[interface{}][]interface{})graph["切爾西"] = []interface{}{"曼城", "熱刺", "米德爾斯堡", "埃弗頓", "南安普頓", "曼聯", "萊切斯特城", "胡爾城", "伯恩利", "沃特福德", "西漢姆"}graph["阿森納"] = []interface{}{"西漢姆", "伯恩茅斯", "桑德蘭", "斯旺西", "伯恩利", "切爾西", "胡爾城", "南安普頓", "沃特福德"}graph["利物浦"] = []interface{}{"桑德蘭", "沃特福德", "水晶宮", "西布羅姆維奇", "斯旺西", "胡爾城", "切爾西", "萊切斯特城", "阿森納"}graph["曼城"] = []interface{}{"水晶宮", "伯恩利", "西布羅姆維奇", "斯旺西", "伯恩茅斯", "曼聯", "西漢姆", "斯托克城", "桑德蘭"}graph["熱刺"] = []interface{}{"斯旺西", "西漢姆", "曼城", "米德爾斯堡", "桑德蘭", "斯托克城", "水晶宮"}graph["曼聯"] = []interface{}{"斯旺西", "萊切斯特城", "胡爾城", "南安普頓", "伯恩茅斯"}graph["西布羅姆維奇"] = []interface{}{"沃特福德", "伯恩利", "萊切斯特城", "西漢姆", "伯恩茅斯", "水晶宮"}graph["埃弗頓"] = []interface{}{"西漢姆", "斯托克城", "西布羅姆維奇"}graph["斯托克城"] = []interface{}{"伯恩利", "沃特福德", "斯旺西", "胡爾城", "桑德蘭"}graph["伯恩茅斯"] = []interface{}{"利物浦", "斯托克城", "胡爾城", "埃弗頓", "西布羅姆維奇"}graph["沃特福德"] = []interface{}{"萊切斯特城", "胡爾城", "米德爾斯堡", "曼聯", "西漢姆"}graph["南安普頓"] = []interface{}{"埃弗頓", "伯恩利", "西漢姆", "斯旺西"}graph["米德爾斯堡"] = []interface{}{"胡爾城", "伯恩茅斯", "桑德蘭"}graph["水晶宮"] = []interface{}{"南安普頓", "桑德蘭", "斯托克城", "米德爾斯堡"}graph["埃弗頓"] = []interface{}{"西漢姆", "米德爾斯堡", "桑德蘭"}graph["伯恩利"] = []interface{}{"水晶宮", "埃弗頓", "沃特福德", "利物浦"}graph["萊切斯特城"] = []interface{}{"水晶宮", "伯恩利", "斯旺西"}graph["西漢姆"] = []interface{}{"桑德蘭", "水晶宮", "伯恩茅斯"}graph["桑德蘭"] = []interface{}{"萊切斯特城", "胡爾城", "伯恩茅斯"}graph["胡爾城"] = []interface{}{"南安普頓", "斯旺西", "萊切斯特城"}graph["斯旺西"] = []interface{}{"水晶宮", "伯恩利"}output := tarjan.Connections(graph)fmt.Printf("%d, %v\n", len(output[0]), output)} |