answersLogoWhite

0


Best Answer

The correctness of either Prim's or Kruskal's algorithm, is not affected by negative edges in the graph. They both work fine with negative edges.

The question boils down to "Does a Priority Queue of numbers work with negative numbers?" because of the fact that both Prim's and Kruskal's algorithm use a priority queue. Of course -- as negative numbers are simply numbers smaller than 0. The "<" sign will still work with negative numbers.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Will either kruskal or prim's algorithm work on negative edge graph?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is krushkal algorithm?

Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component). Kruskal's algorithm is an example of a greedy algorithm.


What is the complexity of kruskal's minimum spanning tree algorithm on a graph with n nodes and e edges?

o(eloge)


Why prims algorithm is better than kruskals algorithm?

"What are difference between Prim's algorithm and Kruskal's algorithm for finding the minimum spanning tree of a graph?" Prim's method starts with one vertex of a graph as your tree, and adds the smallest edge that grows your tree by one more vertex. Kruskal starts with all of the vertices of a graph as a forest, and adds the smallest edge that joins two trees in the forest. Prim's method is better when * You can only concentrate on one tree at a time * You can concentrate on only a few edges at a time Kruskal's method is better when * You can look at all of the edges at once * You can hold all of the vertices at once * You can hold a forest, not just one tree Basically, Kruskal's method is more time-saving (you can order the edges by weight and burn through them fast), while Prim's method is more space-saving (you only hold one tree, and only look at edges that connect to vertices in your tree).


Which is the best shortest path algorithm?

dijkstra's algorithm (note* there are different kinds of dijkstra's implementation) and growth graph algorithm


How does Prim's algorithm differ from Kruskal's and Dijkstra's algorithms?

First a vertex is selected arbitrarily. on each iteration we expand the tree by simply attaching to it the nearest vertex not in the tree. the algorithm stops after all yhe graph vertices have been included.. one main criteria is the tree should not be cyclic.

Related questions

What is krushkal algorithm?

Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component). Kruskal's algorithm is an example of a greedy algorithm.


What is the complexity of kruskal's minimum spanning tree algorithm on a graph with n nodes and e edges?

o(eloge)


Why prims algorithm is better than kruskals algorithm?

"What are difference between Prim's algorithm and Kruskal's algorithm for finding the minimum spanning tree of a graph?" Prim's method starts with one vertex of a graph as your tree, and adds the smallest edge that grows your tree by one more vertex. Kruskal starts with all of the vertices of a graph as a forest, and adds the smallest edge that joins two trees in the forest. Prim's method is better when * You can only concentrate on one tree at a time * You can concentrate on only a few edges at a time Kruskal's method is better when * You can look at all of the edges at once * You can hold all of the vertices at once * You can hold a forest, not just one tree Basically, Kruskal's method is more time-saving (you can order the edges by weight and burn through them fast), while Prim's method is more space-saving (you only hold one tree, and only look at edges that connect to vertices in your tree).


What is difference between resource allocation graph and resource allocation graph algorithm?

The graph is the the actual picture that shows the resource allocation; the algorithm is the method used to produce that graph.


Difference between a and ao?

the main difference between the A*(A star) and AO*(AO star) algorithms is that A* algo is a OR graph algorithm and AO* is a AND-OR graph algorithm. In OR graph algorithm it just find only one solution (i.e either OR solution means this OR this OR this). But in the AND-OR graph algo it find more than one solution by ANDing two or more branches. for more details on AND-OR graph &amp; OR graph please refer the book "Artificial Intelligence" by Elaine Rich &amp; Kevin Knight.


Which is the best shortest path algorithm?

dijkstra's algorithm (note* there are different kinds of dijkstra's implementation) and growth graph algorithm


An algorithm to find whether a directed graph is connected or not?

You can use a The Depth-First Search algorithm.


How does Prim's algorithm differ from Kruskal's and Dijkstra's algorithms?

First a vertex is selected arbitrarily. on each iteration we expand the tree by simply attaching to it the nearest vertex not in the tree. the algorithm stops after all yhe graph vertices have been included.. one main criteria is the tree should not be cyclic.


What is a divergent bar graph?

A graph with a data spread which is both positive and negative can be displayed on a divergent bar graph. These could be constructed on either the x or y axis. Most of you will have seen such a graph which has been drawn on a population pyramid.


What is a negative cycle in Graph?

In a weighed graph, a negative cycle is a cycle whose sum of edge weights is negative


What are the deadlock detection algorithms?

Deadlock is a scenario where two or more processes are blocked, each waiting for the other to release the necessary resources to complete their execution. This situation can cause the entire system to become unresponsive, leading to reduced performance and potentially crashing the system. To avoid this, it is essential to have an effective deadlock detection algorithm in place. Several deadlock detection algorithms are used in modern computer systems. These algorithms use different approaches to detect deadlocks, and each algorithm has its strengths and weaknesses. Wait-for Graph Algorithm: The wait-for graph algorithm is a commonly used deadlock detection algorithm. In this algorithm, a directed graph is created, where the nodes represent the processes, and the edges represent the resources they are waiting for. The algorithm checks if there is a cycle in the graph. If there is a cycle, there is a deadlock in the system. The wait-for-graph algorithm has a few limitations. It can only detect deadlocks and does not provide any mechanism to recover from them. Also, the algorithm may only work well in large systems with a few resources. Resource Allocation Graph Algorithm: The resource allocation graph algorithm is another widely used deadlock detection algorithm. This algorithm creates a graph where the nodes represent the processes and the resources they hold or need. The algorithm checks for cycles in the graph. If there is a cycle, there is a deadlock in the system. The resource allocation graph algorithm is easy to implement and provides an efficient way to detect deadlocks. However, the algorithm requires considerable memory to store the graph, and it can be slow in large systems. Banker's Algorithm: The Banker's algorithm is a resource allocation and deadlock avoidance algorithm. In this algorithm, each process is given a maximum limit on the number of resources it can use. The algorithm checks if granting the requested resources will result in a safe state or not. If the state is safe, the resources are allocated to the process. If the condition is unsafe, the process is put on hold. The Banker's algorithm is an efficient way to prevent deadlocks. However, it requires considerable overhead to maintain the system's state, and it may only work well in systems with a few resources. Ostrich Algorithm: The Ostrich algorithm is a dynamic deadlock detection algorithm. This algorithm assumes a process is deadlocked if it does not progress for a specified period. The algorithm periodically checks the progress of each method and detects if any process is deadlocked. The Ostrich algorithm is efficient in detecting deadlocks in dynamic systems. However, it may not work well in systems where the processes are short-lived, and the algorithm may not detect deadlocks that occur over a short period. Timeout-based Algorithm: The timeout-based algorithm is another dynamic deadlock detection algorithm. This algorithm sets a timer for each resource request made by a process. If the requested resource is not allocated within the specified time, the process is assumed to be deadlocked. The timeout-based algorithm is an efficient way to detect deadlocks in dynamic systems. However, the algorithm may not work well in systems where the processes are short-lived, and it may produce false positives if the time-out period is too short.


When you graph a quadratic function what will the shape of the graph be?

A parabola. An arch opening either north or south of the x-axis depending on the sign of the coefficient (negative opens down, positive opens up).