markdown
Graph Basicsmd 74b4241
lecture/information/graph/graph-basics.lecture.n.md
Download PDF

Graph Basics

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

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
タブを全て閉じる