リソース · ガイド・記事
Travelling Salesman Problem
すべての都市を巡って戻る最短の周回路を求める巡回セールスマン問題を提示し、それを重み付き無向グラフとしてモデル化する方法を示しています。
確認日
元のサイトを開く: Travelling Salesman Problem (元のサイトを新しいタブで開きます)このトピックを練習グラフ の問題で練習用面接官を開きます。
ロードマップに追加
取り組んでいるロードマップにこのリソースを追加できます。自分用の追加リソースとして表示され、ロードマップの手順は変わらず、記録した手順数にも数えられません。
出典コンテンツの言語:英語
The travelling salesman problem (TSP) asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?" Solution of a travelling salesman problem: the black line shows the shortest possible loop that connects every red dot. TSP can be modelled as an undirected weighted graph, such that cities are the graph's vertices, paths are the graph's edges, and a path's distance is the edge's weight. It is a minimization problem starting and finishing at a specified vertex after having visited each other vertex exactly once. Often, the model is a complete graph (i.e. each pair of vertices is connected by an edge). If no path exists between two cities, adding an arbitrarily long edge will complete the graph without affecting the optimal tour.
PrepKit の概要
この概要は PrepKit 編集部がソースリポジトリをもとに執筆・確認したもので、リソース本文の引用ではありません。
- 対象
- ソースにレベルの記載はありません
- 形式
- リファレンス
扱っている内容
- グラフによるモデル。都市を頂点、道路を重み付きの辺とし、ほかの各頂点を一度ずつ訪れる周回路を求める
- 直接の道がない2都市の間を、任意に長い辺で結んでグラフを完全にする方法
使い方
PrepKit の学習アドバイスであり、ソースの主張ではありません。
小さな問題を二通りの方法で解いてください。まずすべての順列を試し、次にビットマスクを使った動的計画法で解きます。自分で作った4都市の例で、両方が同じ周回路の長さを返すことを確認しましょう。
範囲と制約
問題の記述のみです。アルゴリズム、ヒューリスティック、計算量の議論、コードの解説はなく、参考資料はWikipediaだけです。
利用方法と形式
MITライセンスのtrekhleb/javascript-algorithmsリポジトリ内のGitHub上のREADMEで、英語で無料で読めます。
PrepKit が 2026/10/02 に確認しました。 リソースの出典のコミット: 85293e3e2b88
この概要の根拠
- src/algorithms/graph/travelling-salesman/README.md
この項目を掲載しているページ
PrepKit ニュースレターを受け取る
任意です。PrepKit の利用には必要ありません。