Algorithm:
- Above each vertex shows the cost of time.
- Distance / Completion
- The algorithm us back a linked list with nodes in the graph, in descending order time finalization.
- Once ordered and topologically can see precedence of the tasks:
- Get the shirt before the belt and jersey.
- Get the pants before shoes and belt .
- Put on socks before shoes.
Pseudocode:
- For each vertex "or" that the graph belongs to:
- The state "or" not visited, that algorithm is started .
- The parent should be null, because it has no predecessors.
- The time starts from 0, obviously that starts the algorithm.
- Then, if the state = not visited then: It starts the topological management.
- Visited The state will change to that and was visited and analyzed their s predecessors.
- So we add a 1 at the time because it is so slow at the apex .
- Then for each vertex adjacent do:
- If Status = Not visited then:
- 's father will now be the vertex , as is next in order.
- When the state of vertex = Completed:
- times are added together and this would be the total cost for the system.
- result is inserted in the list sorting algorithm topological .
Asymptotic Analysis :
The analysis asymptotic algorithm of of topological management is costly to pursue vertex without predecessors, several times.
The solution would pre-calculate how many predecessors of each vertex , store data in a vector update whenever adding a new vertex to solution.
Time Cost:
- Initialization:
First loop: O (n) --- means that will depend on the number of vertices that has the graph.
Second loop: Examination of all edges.
O (a + n) --- For adjacency lists.
O (n ^ 2) --- For adjacency matrix.
- Main Loop:
O (a + n) --- For adjacency lists.
O (n ^ 2) --- For adjacency matrix.
Data Structures:
- linked list: For this algorithm topological management, linked lists are used as the management already completed is a simple linear list of edges connecting the same way it had before.
- Isomorphism: Something has to do with ismorfismo , but are not related and is acyclic graph algorithm allows align vertices, while keeping the links between each of the vertices , ie accommodates only priority, but retains its structure .
- Trees: can also be said that this related to trees as these contain nodes also called vertices, and the trees come in different forms of organization.
- depth Search (DFS ): The topological management needs search algorithm DFS because you need to apply to go exploring nodes, and finally reach a linear order .
Applications:
- can be applicable to the reprecentacion phase of a project, where vertices represent tasks and edges relations time to them.
- Evaluation phase a semantic compiler.
- In everyday life it could implement simple things such as organizing utility bills to pay, because these days come in different , and differ in price and maturity, and to apply this algorithm, could sort in order of priority due to paying cash them in order, but we spend and spend no money to pay.
- We also would serve to find any cycle in a graph and identify it.
- also to find a problem or defect in a topological order algorithm.
Self
Personally this project and the other four I have been very helpful since the majority of topics covered were new to me, and I realized that are of great usefully applied to everyday life in relation to the management of topological, since I left as teaching to cases in which I can apply this algorithm. learned that a particular task is a (s) by seniority and other (s) as a result of this task, and that ultimately after are linked to one another. In conclusion from now on things that have to do that you can implement this algorithm, I facilitate the task, and therefore time and effort.
any doubt or question you have to leave your comment and I will answer the earliest possible time.
0 comments:
Post a Comment