1. Trang chủ
  2. » Luận Văn - Báo Cáo

Lecture 12_Graphs_Part2.Pptx

39 4 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 39
Dung lượng 1,46 MB

Nội dung

Algorithms on graphs Algorithms on graphs Computational Science and Engineering Outlines • Graph revisit • Topological sorting • Minimum spanning trees 2 Graphs • A graph is a pair (V, E), where – V i[.]

Algorithms on graphs Computational Science and Engineering Outlines • Graph revisit • Topological sorting • Minimum spanning trees Graphs • A graph is a pair (V, E), where – V is a set of nodes, called vertices – E is a collection of pairs of vertices, called edges – Vertices and edges are positions and store elements • Example: 33 HNL 255 LAX 123 80 – A vertex represents an airport and stores the three-letter airport code – An edge represents a flight route between two airports and 84 PVD stores the mileage of the routeOR 18 D 14 SFO DF W LGA 138 11 10 9 MIA Travel on graphs BFS DFS 1 10 1 12 10 11 Topological Sorting • Number vertices, so that (u,v) in E implies A typical student u < v wake up day study computer sci nap pla y eat write c.s program make cookies for professors sleep0 more c.s work out 1 dream about graphs Naïve algorithms Method TopologicalSort(G) H ← G // Temporary copy of G n ← G.numVertices() while H is not empty for each vertex v if v be a vertex with no outgoing edges then Label v ← n n←n-1 Remove v from H Complexity: O(n3) Naïve algorithms wake up study computer sci eat nap pla y more c.s write c.s program work out make cookies for professors sleep 1 dream about graphs Naïve algorithms wake up study computer sci eat nap pla y more c.s write c.s program work out make cookies for professors 10 sleep Naïve algorithms wake up study computer sci eat nap pla y more c.s write c.s program work out make cookies for professors Naïve algorithms wake up study computer sci nap pla y eat write c.s program make cookies for professors sleep0 more c.s work out 1 dream about graphs

Ngày đăng: 27/10/2023, 11:01