bool bpm(bool bpGraph[M][N], int u, bool seen[], int
matchR[])
{
// Try every job one by one
for (int v = 0; v < N; v++)
{
// If applicant u is interested in job v and v is
// not visited
if (bpGraph[u][v] && !seen[v])
{
seen[v] = true; // Mark v as visited
// If job 'v' is not assigned to an applicant OR
// previously assigned applicant for job v (which is
matchR[v])
// has an alternate job available.
// Since v is marked as visited in the above line, matchR[v]
// in the following recursive call will not get job 'v' again
if (matchR[v] < 0 || bpm(bpGraph, matchR[v], seen,
matchR))
{
matchR[v] = u;
return true;
}
}
}
return false;
}
// Returns maximum number of matching from M to N
int maxBPM(bool bpGraph[M][N])
{
// An array to keep track of the applicants assigned to
// jobs. The value of matchR[i] is the applicant number
// assigned to job i, the value -1 indicates nobody is
// assigned.
int matchR[N];
// Initially all jobs are available
memset(matchR, -1, sizeof(matchR));
int result = 0; // Count of jobs assigned to applicants
for (int u = 0; u < M; u++)
{
// Mark all jobs as not seen for next applicant.
bool seen[N];
memset(seen, 0, sizeof(seen));
// Find if the applicant 'u' can get a job
if (bpm(bpGraph, u, seen, matchR))
result++;
}
return result;
}
Show the reduction of the following bipartite matching problem to a single-source, single-sink problem. Show your...
o8: (5 marks) the maximum-matching algorithm to the following bipartite graph: Apply 2 8 9 10
1. Define the following terms in your own words. Flux: Source: Sink: Fixation:
Suppose that each source si in a multisource, multisink problem produces exactly pi units of flow, so that f(si, = pi. Suppose also that each sink tj consumes exactly qj units, so that f(V, tj) = qj, where Li Pi = £; 9;. Show how to convert the problem of finding a flow f that obeys these additional constraints into the problem of finding a maximum flow in a single-source, single-sink flow network.
Apply Dijkstra's algorithm as discussed in class to solve the single-source shortest-paths problem for the following graph. Consider node A to be the source. (20 points) a. Show the completed table. b. State the shortest path from A to E and state its length. State the shortest path from A to F A 9 and state its length. d. State the shortest path from A to G 17 and state its length. 7 C. 12 B 8 10 D 8...
5. Apply Dijkstra's algorithm as discussed in class to solve the single-source shortest-paths problem for the following graph. Consider node A to be the source. (20 points) a. Show the completed table. b. State the shortest path from A to E and state its length. C. State the shortest path from A to F and state its length. d. State the shortest path from A to G and state its length. A 12 9 B 17 8 7 10 8...
show that the single-source shortest paths constructed by dijkstra's algorithm on a connected undirected graph from a spinning tree
2. Apply Dijkstra’s algorithm as discussed in class to solve the single-source shortest-paths problem for the following graph. Consider node a to be the source. (10 points) a. Show the completed table. b. State the shortest path from A to J and state its length. c. State the shortest path from A to K and state its length. d. State the shortest path from A to L and state its length. 3 5 6 4 3 2 1 2. d...
Problem 6. (Weighted Graph Reduction) Your friend has written an algorithm which solves the all pairs shortest path problem for unweighted undirected graphs. The cost of a path in this setting is the number of edges in the path. The algorithm UNWEIGHTEDAPSP takes the following input and output: UNWEİGHTEDA PSP Input: An unweighted undirected graph G Output: The costs of the shortest paths between each pair of vertices fu, v) For example, consider the following graph G. The output of...
Show that the decision version of the knapsack problem is NP-complete. (Hint: In your reduction, make use of the partition problem: given n positive integers, partition them into two disjoint subsets with the same sum of their elements. The partition problem is NP-complete.)
matlab problem Problem 3 Impedance matching concept in electrical circuits states that the maximum power to a loa when the load resistance is matched to the internal resistance of the source. Show that this is true by plotting the power to the load RL and that it is maximum when is equal to the source resistance Rs for a source of 10 v DC and internal resistance Rs of load RL in series. Fit the power vs resistance to a...