Learning data structure_5 _ figure (2)

Source: Internet
Author: User
Tags jlink

The weather is getting hotter and hotter, so you have to calm down when reading a book. Today we will continue to figure this chapter. There are many concepts and algorithms. The first time we look at it, we will give priority to breadth, in the future, if you want to use specific algorithms, go to "Introduction to algorithms. The following are the learning content and notes.

Graph)

1. Graph Storage Structure

Adjacent matrix: vertex array + edge array (Binary). The Edge array of an undirected graph is a symmetric matrix, and the directed graph is asymmetric (the row element and the output degree of the table vertex and, the column corresponds to the inbound and). The elements in the edge array of the graph change from boolean to weight.

Adjacent table: vertex table (Data + firstedge) + edge table (adjvex + next); edge table of Directed Graph split edge table and inbound edge table; weighted network chart, add a weight data field to the edge table.

Cross Linked List: optimizes the directed graph list. It combines the list of adjacent tables with the list of inverse adjacent tables to redefine the vertex table (Data + firstin + firstout ), edge table node structure (tailvex arc tail subscript + headvex arc header subscript + headline + taillink); the time complexity of the algorithm creation is the same as that of the adjacent table, however, both the outbound and inbound degrees can be easily obtained-Focus on the vertex.

Multiple adjacent tables: This is an optimization for undirected graph adjacent tables. The Edge table structure (ivex + ilink + jvex + jlink) is redefined. The ivex and jvex tables have two vertices of one edge, the ilink table points to the next edge that is attached to the vertex ivex, And the jlink table points to the next edge that is attached to the vertex jvex. In the same table, the adjacent table is represented by two vertices, and the adjacent table is represented by one vertex-followed edge.

Edge set number group: it consists of two one-dimensional arrays, vertex array + edge array (begin + end + weight ).

2. Graph Traversal

Depth first search and breadth first BFS (breadth first search ).

3. Minimal Spanning Tree

The spanning tree of a connected graph (with weight) is a very small connected subgraph. It contains all N vertices and only contains n-1 edges that are enough to form a tree, the minimum cost Spanning Tree that constitutes a connected network is called the least spanning tree.

Prim (prim) algorithm: N = (V, {e}) is a connected graph. At the beginning, a point of U is taken from V and merged into the vertex set U, and a little VI is obtained from the V-U, take a UI from u to minimize the (ui, vi) Permission and merge VI into U. Repeat the above process until u = v.

Kruskal algorithm: strict version of p175.

4. Shortest Path

Definition: refers to the path with the least sum of edge weights between the Source Vertex and the final vertex.

Dijkstra (dijela) algorithm: Initial State: d [J] = min {d [I] | Vi belongs to v}; the end of the sub-short path is VK, the next short path is either (v, VK) or (v, VJ, VK ).

Floyd algorithm: three for loops.

5. topological sorting: AOV network; topological sorting algorithm: Establish an adjacent table, vertex table (in + Data + firstedge) + edge table -- Solve whether the project can proceed smoothly and give the order of vertex.

6. key Path: AOE network; the shortest time required to complete the project -- note that the shortest path is different from the shortest path. The key path is the path with the greatest weight and time in the network, that is, the key path. The algorithm principle is calculated by ETV (obtained through topological sorting calculation) and LTV to obtain ete and LTE, determine whether an AK is a key activity in a key path based on whether ete [k] And LTE [k] are equal.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.