Graph algrithm thuật toán trong đồ thị

180 1.3K 0
Graph algrithm   thuật toán trong đồ thị

Đ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

GRAPHS basic algorithms (4) • Breadthfirst search TeX • Dfs • Topological sorting TeX • Search connected components TeX strongly connected components, bridges, etc. (4) • Search strongly connected component, condensation build a graph for O (N + M) TeX • Search for bridges O (N + M) TeX • Search articulation points for the O (N + M) TeX • Search bridges online in O (1) an average of TeX the shortest path from one vertex (4) • Dijkstras algorithm finding the shortest paths from a given vertex to all other vertices of O (N 2 + M) TeX • Dijkstras algorithm for sparse graphs of finding the shortest paths from a given vertex to all other vertices of O (M log N) TeX • BellmanFord algorithm for finding the shortest paths from a given vertex to all other vertices of O (NM) TeX • Leviticus algorithm of finding the shortest paths from a given vertex to all other vertices of O (NM) shortest paths between all pairs of vertices (2) • Finding the shortest paths between all pairs of vertices in the graph by FloydUorshella in O (n 3 ) TeX • Counting the number of fixedlength paths between all pairs of vertices, finding the shortest path of fixed length in O (n 3 log k) TeX the minimum spanning tree (5) • The minimum spanning tree. Prims algorithm in O (n 2 ) and O (m log n) TeX • The minimum spanning tree. Kruskals algorithm for O (M log N + N 2 ) • The minimum spanning tree. Kruskals algorithm with the data structure a system of disjoint sets for O (M log N) • Kirchhoff matrix theorem. Finding the number of spanning trees of O (N 3 ) • Prüfer code. Cayley formula. The number of ways to make a graph connected TeX cycles (3) • Finding a negative cycle in the graph of O (NM) TeX • Finding Euler Euler path or cycle of O (M) • Checking on the graph is acyclic and finding cycle of O (M) lowest common ancestor (LCA) (5) • Lowest common ancestor. Finding of O (sqrt (N)) and O (log N) with preprocessing O (N) • Lowest common ancestor. Finding of O (log N) with preprocessing O (N log N) (Binary lifting method) • Lowest common ancestor. Finding the O (1) preprocessing with O (N) (algorithm FarahColton and Bender) • The task RMQ (Range Minimum Query at least in the interval). Solution in O (1) preprocessing O (N) • Lowest common ancestor. Finding the O (1) in offline mode (Tarjan algorithm) TeX flows and related problems (10) • EdmondsKarp algorithm for finding the maximum flow of O (NM 2 ) • Method push predpotoka finding the maximum flow of O (N 4 ) • Modification of the method of pushing predpotoka for O (N 3 ) • Flow restrictions • The flow of minimum cost (mincostflow). Algorithm for ways to increase the O (N 3 M) • Assignment problem. Solution with a mincostflow of O (N 5 ) • Assignment problem. Hungarian algorithm (algorithm Kuna) for O (N 3 ) TeX • Finding the minimum cut algorithm for Curtains, Wagner O (N 3 ) TeX • The flow of minimum cost, minimumcost circulation. Algorithm for removing negative weight cycles TeX • Dinics algorithm for finding the maximum flow TeX matchings and related problems (6) • Kuhns algorithm for finding the greatest matchings of O (NM) TeX • Checking on the graph bipartition and splitting into two parts for the O (M) • Finding the maximum weight vertexweighted matchings of O (N 3 ) • Edmonds algorithm for finding maximum matching in an arbitrary graph of O (N 3 ) TeX • Floor ways directed acyclic graph TeX • Tutte matrix. Randomized algorithm for finding maximum matching in an arbitrary graph TeX connection (3) • Edged connectivity. Properties and finding TeX • Vertex connectivity. Properties and finding TeX • Graphing with the specified vertex and rib connections and the lower of the degrees of the vertices TeX By ways (0) Inverse Problems (2) • The inverse problem of SSSP (inverseSSSP inverse problem of shortest paths from a single vertex) for O (M) • The inverse problem of MST (inverseMST inverse problem minimum spanning tree) for O (NM 2 ) Miscellaneous (3) • Paint the edges of the tree (data structure) decision in O (log N) • Task 2SAT (2CNF). The decision is O (N + M) • Heavylight decomposition TeX BASIC ALGORITHMS Breadthfirst search Breadthfirst search (bypassing the width, breadthfirst search) is one of the basic algorithms on graphs. As a result of searching the shortest path width is the length in unweighted graph, that is, path that contains the smallest number of edges. The algorithm works for , where the number of vertices number of edges. Description of the algorithm The input to the algorithm is fed given graph (unweighted), and number of starting vertex . A graph can be either oriented or unoriented, this algorithm is not important. The algorithm itself can be understood as a process of ignition of the graph: at the zero step ignite only the tip . At each step the fire already burning with each vertex spreads to all its neighbors; ie in one iteration of the algorithm is an expansion of the ring of fire in width per unit (hence the name of the algorithm). More rigorously, this can be represented as follows. Lets create a place in which to fit the top of the burning, and zavedёm Boolean array in which each vertex will celebrate, lit it already or not (in other words, whether she had). Initially placed in a queue is just the tip , and , as for all other vertices . Then the algorithm is a loop: while the queue is not empty, get out of her head one vertex, view all edges emanating from that vertex, and if some of the peaks is not viewed burn, then set them on fire and put it in the queue. As a result, when the queue is empty, bypassing the width will bypass all reachable from the vertex, with up to each reaches the shortest way. You can also calculate the length of the shortest paths (which just need to have an array of lengths of paths ), and compact to save information sufficient to recover all of these shortest paths (you have to have an array of ancestors , in which each vertex to store vertex number for which we got into this vertex). Implementation Implement the above algorithm in C ++. Input data: vector < vector > g; граф int n; число вершин int s; стартовая вершина (вершины везде нумеруются с нуля) чтение графа ... Himself bypass: queue q; q.push (s); vector used (n); vector d (n), p (n); useds = true; ps = 1; while (q.empty()) { int v = q.front(); q.pop(); for (size_t i=0; i

Ngày đăng: 11/05/2015, 05:58

Từ khóa liên quan

Mục lục

  • GRAPHS

    • basic algorithms (4)

    • strongly connected components, bridges, etc. (4)

    • the shortest path from one vertex (4)

    • shortest paths between all pairs of vertices (2)

    • the minimum spanning tree (5)

    • cycles (3)

    • lowest common ancestor (LCA) (5)

    • flows and related problems (10)

    • matchings and related problems (6)

    • connection (3)

    • By way-s (0)

    • Inverse Problems (2)

    • Miscellaneous (3)

    • BASIC ALGORITHMS

    • Breadth-first search

      • Description of the algorithm

      • Implementation

      • The application of the algorithm

      • Tasks in the online judges

      • Dfs

        • Applying the algorithm

        • Implementation

Tài liệu cùng người dùng

Tài liệu liên quan