Using python; We wish to use graph theory in order to solve the following problem. A company should carry dierent chemical products P1, P2, : : :, Pk from the factory to a city. For security reasons, some products should not be carried in the same truck: 8i; 0 < i < k; Pi is not compatible with Pi+1. Moreover Pk is not compatible with P1. 1) Write a comment: how can we state an undirected graph that visually represents this problem: 1. What are the vertices, what are the edges? 2. What is the specic property of this graph? 2 2) Write an algorithm that, given an integer k > 1, returns the minimum number of trucks necessary to carry all the products.
1)
1. There are k vertices in this graph; each corresponding to a chemical product. There will be an edge between two nodes in the graph if and only if they are compatible.
2. This graph will be the complement graph to the cycle graph with k nodes.
2)
Algorithm to find the minimum number of trucks necessary to carry all the products:
## Python code begins ##
def minTrucks(k):
if k % 2 == 0:
return 2
else:
return 3
## Python code ends ##
How this works:
If there are even number of products, you can do just 2 trucks --- even numbered products in one truck and odd numbered products in the other. The first and kth product will go in separate trucks.
If there are odd number of products, you can still do a similar distribution but now the first and the kth product will go in the same truck. That can't be allowed, so you'll need a third truck to take the kth product.
Using python; We wish to use graph theory in order to solve the following problem. A...
Say that we have an undirected graph G(V, E) and a pair of vertices s, t and a vertex v that we call a a desired middle vertex . We wish to find out if there exists a simple path (every vertex appears at most once) from s to t that goes via v. Create a flow network by making v a source. Add a new vertex Z as a sink. Join s, t with two directed edges of capacity...
Problem 6. In lecture, we saw that an undirected graph with n nodes can have at most n(n - 1)/2 edges. Such a graph necessarily has one connected component. The greatest number of edges possible in a disconnected graph, however, is smaller. Suppose that G (V, E) is a disconnected graph with n nodes, how large can |El possibly be? You do not need to prove your answer, but you should provide some explanation of how you obtained it.
Name.... * an10 a) Solve the following problem using graphical method (using the following graph): 2. Minimize f(x,y)=2x-y subject to the constraints x2+ y2s 20. y Sx (1) (2) (In the space provided below the graph, please write down your solution clearly) b) Suppose we wish to solve the above problem using Exterior Penalty Function approach. Define an augmented cost function and explain how to use it to find a solution to the above problem.
Name.... * an10 a) Solve...
Name.... * an10 a) Solve the following problem using graphical method (using the following graph): 2. Minimize f(x,y)=2x-y subject to the constraints x2+ y2s 20. y Sx (1) (2) (In the space provided below the graph, please write down your solution clearly) b) Suppose we wish to solve the above problem using Exterior Penalty Function approach. Define an augmented cost function and explain how to use it to find a solution to the above problem.
Name.... * an10 a) Solve...
a) Solve the following problem using graphical method (using the following graph): Minimize f(x,y) - 2x-y subject to the constraints x2+y's 20 y<x (1) (2) (In the space provided below the graph, please write down your solution clearly) we wish to solve the above problem using Exterior Penalty Function approach. Define b) Suppose augmented cost function and explain how to use it to find a solution to the above problem.
a) Solve the following problem using graphical method (using the...
Please write legibly
Bonus problem: Use graph theory to solve the following problem. Let A be an n by n array in which no two rows are identical. Show that it is possible to delete some column so that in the resulting n by n-1 array, no two rows are equal. . LetA rows are identical. Show that it impos
Have the explaination please.
4 Graph Application: Network Connectivity (Adapted from Problem 9, Chapter 3 of K&T) Think of a communications network as a connected, undi rected graph, where messages from one node s to another node t are sent along paths from s to t. Nodes can sometimes fail. If a node v fails then no messages can be sent along edges incident on v. A network is particularly vulnerable if failure of a single node v can cause...
In this problem, you are expected to implement Prim's Algorithm on an undirected simple graph. Write a method that is part of a class that implements Graph as an adjacency matrix. This method should generate a minimum spanning tree using Prim's Algorithm, and print out the edge added by the algorithm on each iteration. 3 10 4 8 Output: 1 2 1 3 34 35 5 6 17 3 12 34 5 1 6 8 20 4 Output: 26 65...
Use sorting techniques in the language Python 3
Devise an algorithm and implement it in a program to solve the following problem, similar to one often faced by an MP3 player. For our purposes, a song consists of the following data fields: title (a nonempty ASCII string) composer (a (possibly empty) ASCII string), running time (a positive integer). Input consists of n songs and an integer k with 1 Sksn. Your program must find the k songs with longest running...