markdown
グラフの基本md 74b4241
lecture/information/graph/graph-basics.lecture.n.md
Download PDF

グラフの基本きほん

date2026-07-14document_iddoc_7e6024074b2e40e0772916eed50e48d0description対象間の関係を頂点と辺で表すグラフの定義、隣接、道、距離、連結性を整理し、探索アルゴリズムの前提を構成する。prerequisites集合の基本 / 写像と関係の基本type講義statusactiverelateddata/lecture/information/discrete-math/sets-and-maps-basics.lecture.n.md / data/lecture/information/algorithm/search/dfs-and-bfs-basics.lecture.n.md
informationgraphundergraduatelecture

1導入どうにゅう

この講義こうぎでは、対象間たいしょうかん関係かんけい頂点ちょうてんへんあらわすグラフの定義ていぎと、探索たんさく記述きじゅつするために必要ひつよう隣接りんせつみち距離きょり連結性れんけつせい説明せつめいする。

道路網どうろもうでは交差点こうさてんかたちより接続関係せつぞくかんけい重要じゅうようであり、通信網つうしんもうでは機器きき外観がいかんより通信可能性つうしんかのうせい重要じゅうようである。グラフは、対象たいしょうそのものから関係かんけいだけを抽出ちゅうしゅつし、ことなる問題もんだいおな構造こうぞうとしてあつかうための表現ひょうげんである。

2用語ようご定義ていぎ

グラフ G=(V,E) は、頂点ちょうてん集合しゅうごう Vへん集合しゅうごう E からなる。頂点ちょうてん対象たいしょうを、へんふたつの対象間たいしょうかん関係かんけいあらわす。この講義こうぎ無向むこうグラフは有限単純ゆうげんたんじゅんグラフであり、

E{{u,v}Vuv}

とする。したがって、自己じこループと多重辺たじゅうへんふくまれない。

有向ゆうこうグラフでは EV×V とし、へん (u,v)u から v へのきをつ。以下いかでは、とくことわらないかぎ有限単純無向ゆうげんたんじゅんむこうグラフをあつかう。

二頂点にちょうてん u,vへん直接結ちょくせつむすばれているとき、uv隣接りんせつするという。頂点ちょうてん v隣接りんせつする頂点ちょうてん集合しゅうごう

N(v)={uV{u,v}E}

く。

3みち距離きょり

頂点列ちょうてんれつ

v0,v1,,vk

かく i=1,,k について {vi-1,vi}Eたすとき、このれつながk歩道ほどうという。さらに v0,,vk相異あいことなるとき、これをみちという。頂点ちょうてん s から v への歩道ほどう存在そんざいするとき、閉路へいろのぞけばみちられるため、vs から到達可能とうたつかのうである。

無重むおもみグラフにおける距離きょり d(s,v) は、s から v へのみちながさの最小値さいしょうちである。みち存在そんざいしない場合ばあいd(s,v)= とする。ここで「無重むおもみ」とは、すべてのへん一歩いっぽとしてかぞえることを意味いみする。

4連結性れんけつせい

任意にんい二頂点にちょうてんあいだみち存在そんざいする無向むこうグラフを連結れんけつという。連結れんけつでないグラフは、たがいに到達可能とうたつかのう頂点ちょうてんをまとめた連結成分れんけつせいぶん分解ぶんかいできる。

れいえば

V={a,b,c,d},E={{a,b},{b,c}}

では、a,b,cおな連結成分れんけつせいぶんぞくし、d単独たんどく連結成分れんけつせいぶんをなす。また、d(a,c)=2 である。

5表現方法ひょうげんほうほう

隣接りんせつリストは各頂点かくちょうてん vたいして N(v)保存ほぞんする。頂点数ちょうてんすう|V|辺数へんすう|E| とすると、無向むこうグラフの全隣接ぜんりんせつリストの要素数ようそすう2|E| である。各辺かくへん両端点りょうたんてんのリストに一度いちどずつあらわれるためである。

隣接行列りんせつぎょうれつは、頂点ちょうてん番号ばんごうけ、へん有無うむ行列要素ぎょうれつようそあらわす。へん存在判定そんざいはんてい高速こうそくだが、頂点数ちょうてんすう二乗にじょう比例ひれいする領域りょういき必要ひつようとする。なグラフでは隣接りんせつリストがてきし、みつなグラフやへん存在判定そんざいはんてい頻繁ひんぱんおこな場合ばあい隣接行列りんせつぎょうれつ候補こうほになる。

6探索たんさくへの接続せつぞく

グラフ探索たんさくは、始点してんから隣接頂点りんせつちょうてんじゅん調しらべ、到達可能とうたつかのう頂点ちょうてん列挙れっきょする操作そうさである。この講義こうぎ定義ていぎした頂点ちょうてんへん隣接りんせつみち距離きょりが、DFSとBFSの入力にゅうりょく主張しゅちょう構成こうせいする。

data/lecture/information/algorithm/search/dfs-and-bfs-basics.lecture.n.md

7まとめ

data/exercise/information/algorithm/search/graph-traversal-and-unweighted-distance.exercise.n.md
  • グラフ G=(V,E) は、対象たいしょう頂点ちょうてん関係かんけいへんとしてあらわす。
  • みち相異あいことなる隣接頂点りんせつちょうてんじゅんならべたれつであり、無重むおも距離きょり最短さいたんみち辺数へんすうである。
  • 連結性れんけつせいは、任意にんい二頂点間にちょうてんかん到達可能性とうたつかのうせい定義ていぎされる。
  • 隣接りんせつリストと隣接行列りんせつぎょうれつは、おなじグラフをことなる計算特性けいさんとくせい表現ひょうげんする。

Graph Basics

1Introduction

This lecture defines graphs as representations of relationships between objects and develops adjacency, paths, distance, and connectivity as the concepts required for graph traversal.

In a road network, connectivity matters more than the shapes of intersections. In a communication network, reachability matters more than the appearance of devices. A graph extracts these relationships and allows structurally identical questions to be treated in a common language.

2Terms and definitions

A graph G=(V,E) consists of a set V of vertices and a set E of edges. Vertices represent objects, while edges represent relationships between pairs of objects. An undirected graph in this lecture is a finite simple graph with

E{{u,v}Vuv}.

Thus it contains neither self-loops nor parallel edges.

For a directed graph, EV×V, and an edge (u,v) is oriented from u to v. Unless stated otherwise, the remainder of this lecture considers finite simple undirected graphs.

Two vertices u,v are adjacent when an edge directly joins them. The neighborhood of a vertex v is

N(v)={uV{u,v}E}.

3Paths and distance

A sequence of vertices

v0,v1,,vk

is a walk of length k when {vi-1,vi}E for every i=1,,k. It is a path when v0,,vk are distinct. If a walk from s to v exists, deleting cycles yields a path, and v is reachable from s.

In an unweighted graph, the distance d(s,v) is the minimum length of a path from s to v. If no path exists, set d(s,v)=. Here, “unweighted” means that every edge counts as one step.

4Connectivity

An undirected graph is connected when a path exists between every pair of vertices. A disconnected graph decomposes into connected components, each consisting of vertices that are mutually reachable.

For example, if

V={a,b,c,d},E={{a,b},{b,c}},

then a,b,c form one connected component, while d forms a component by itself. Moreover, d(a,c)=2.

5Representations

An adjacency list stores N(v) for each vertex v. If the graph has |V| vertices and |E| edges, all adjacency lists of an undirected graph contain 2|E| entries in total, because every edge appears once at each endpoint.

An adjacency matrix numbers the vertices and records edge existence in matrix entries. It supports fast edge-existence queries but requires space proportional to the square of the number of vertices. Adjacency lists are suitable for sparse graphs; adjacency matrices are candidates for dense graphs or workloads dominated by edge-existence queries.

6Connection to traversal

A graph traversal starts at a vertex, examines adjacent vertices in a specified order, and enumerates reachable vertices. Vertices, edges, adjacency, paths, and distance as defined here form the input and claims of DFS and BFS.

data/lecture/information/algorithm/search/dfs-and-bfs-basics.lecture.n.md

7Summary

data/exercise/information/algorithm/search/graph-traversal-and-unweighted-distance.exercise.n.md
  • A graph G=(V,E) represents objects as vertices and relationships as edges.
  • A path is a sequence of distinct adjacent vertices, and unweighted distance is the number of edges in a shortest path.
  • Connectivity is defined by reachability between every pair of vertices.
  • Adjacency lists and adjacency matrices represent the same graph with different computational tradeoffs.
raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる