package
Version:
v0.2.0
Opens a new window with list of versions in this module.
Published: May 7, 2026
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package graph は隣接リスト表現のグラフに対する BFS / DFS / Dijkstra を提供する。
BFS は src から幅優先探索を行い、各到達可能ノードへの辺数距離を返す。
到達不能なノードは距離 -1。
DFS は src から反復版の深さ優先探索を行い、訪問したノードを発見順に返す。
Dijkstra は非負重みグラフで src からの最短距離を計算する。
到達不能ノードは math.MaxInt64 を返す。負の重みがある場合は panic する。
AdjList は隣接リスト表現。AdjList[u] は u を始点とする辺の一覧。
type Edge struct {
To int
W int
}
Edge は重み W を持つ有向辺で、終点を To に持つ。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.