- FIG: The predecessor and successor nodes without restriction
- FIG: a directed graph, and edge point set V binding to E and FIGS free
- Multiple FIG: G appears multiple times in an edge
- Of vertices: the degree of penetration, the total degree = number of edges in FIG. 2 *
- Path, the path length, simple path (in addition to not have the same starting point and the starting point of focus), a simple loop
- Subgraph, spanning subgraph
- Communication, strong graph
- Communication component (not unique)
- Weighted graph
- Adjacency matrix storage
- Adjacent table storage (array + chain)
- Depth-first traversal (similar to preorder traversal of the tree), recursive, n for the complexity of the square
- Depth first iterative algorithm: stack, pop-up vertex not visited, unvisited neighbor the stack
- Breadth-first traversal (tree-like hierarchy traversal), queue implementation
- Topological sorting: AOV network does not ring (critical path: commonly used in software engineering)
- The basic idea of topological sorting algorithm: selecting one of the output point 0, deleting the vertex and all edges out, continues until all vertices have or not the output of the point 0 (there is described ring)
- Algorithm: an array of the recording sount
- Thought stack with an array of analog: top, in charge of topological sorting time O (n + e)
- Critical path: the length of the longest path from the source point to sink point
- Recurrence formula earliest time of occurrence, the latest time of occurrence recurrence formula
- Shortest Path: Dijstrka algorithm with: n square complexity
- Floyd algorithm: the shortest path between any two points: n ^ 3
l definition of a n -order square matrix sequence: A (-1) , A (0) , ..., A ( n-. 1 ) .
wherein A (-1) [ I ] [ J ] = Edge [ I ] [ J ] ;
for any 0 ≤ K ≤ n- -1 , A ( K ) [ I ] [ J ] = min { A ( K -1) [ I ] [ J ], A(k-1)[i][k] + A(k-1)[k][j] }。 -
l time complexity : the Floyd time complexity of the algorithm is O (n . 3 ) , and the call n times Dijkstra algorithm for finding the shortest path for each pair of vertices same time complexity.
² dense graph: Practice shows that Floyd algorithm faster
² sparse graph: By using heap, Dijkstra time complexity of the algorithm can be further improved .
l Applicable problem : Dijkstra algorithm is only right for a positive view, and Floyd algorithm allows the figure sideband negative weights, but does not allow the loop contains negatively weights,
l readability : Floyd algorithm is more simple and easy to understand.
- Minimum Spanning Tree: Spanning Tree: (there is only one path connected undirected graph vertices between any) supporting the sub-tree of FIG. + Free, minimum weight
- Prim's algorithm:
l basic steps :
Set N = (V, E, C ) communication network, the TE is N set of edges of the Minimum Spanning Tree.
① beginning of the algorithm, the U-U = { 0 } ( U 0 ∈ V ), the TE = null ;
② satisfying a weight equal tomin{weight(u‘’, v‘’) | u‘’∈U, v‘’∈V-U},
Sides (U, v) , which was added to TE , and the v join the U- .
③ repeated ② , up = V U terminated algorithm. - l storing method Minimum Spanning Tree : auxiliary array the TE [ n- - . 1] to save the set of edges of a minimum spanning tree, each array element of the TE [ I ] indicates that an edge, the TE [ I ] consists of three domain head , tail and cost structure, which are stored the starting point side, and the right end value.
- Time Complexity: N ^ 2
- Kruskal ( Kruskar ) algorithm
-
Provided communication network N = (V, E, C) , T is N the minimum spanning tree. Initial T = {V, { Æ to }} , i.e. T no edge, only n vertices is n a connected component.
① from E to select the smallest weight edge, and this edge from E deletion.
② If two vertices of this edge at T different connected components, then this was added to the edge of T , resulting in T reducing a communication component; otherwise, two vertices of this edge in the same connected component in , does nothing.
③ is repeated ①②, until T when a remaining connected component, terminate the operation.
- (E log e) = O (log n and)
-
l Prim time complexity of the algorithm is O ( n- 2 ) , Minimum Spanning Tree algorithm is applied to find the edge of a dense network.
l Kruskal algorithm contrary, it applies to Minimum Spanning Tree request sparse network side, because of its time complexity is O ( E log n- ) .
-
Figure finishing
Guess you like
Origin blog.csdn.net/qq_38941327/article/details/90647848
Recommended
Ranking