Please help me complete these sub-tasks using Python Programming. Follow the instructions stated below and take not that it should have FIVE FUNCTIONS from FIVE SUB-TASKS (0, 1, 2, 3, 4) as shown.
In the task descriptions, "hashable objects" refer to objects that can be used as elements of sets, or as dictionary keys in Python 3. Sub-task 0: Vertex In-Degree (0%) . Function signature: def in degree (graph, vertex) : . Function arguments: graph - a Graph object whose class definition is specified in the header file vertex - a hashable object, which is guaranteed be an element of graph. vertices . Return value: an int which is equal to the in-degree of the given vertex. . This ungraded sub-task aims to familiarize students with the submission platform, and must be completed before they can attempt Sub-task 1. Sub-task 1: Constraint checking (30%) . Function signature: def check_constraints (graph, source, sink, flow) : . Function arguments: graph - a Graph object whose class definition is specified in the header file source - a hashable object, representing the source vertex sink - a hashable object, representing the sink vertex flow - a dict mapping tuples to positive floats such that flow[(u, v) ] is the assigned flow from vertex u to vertex v. . Return value: a bool which is True if and only if all constraints (CI. C2, C3) are satisfied. Sub-task 2: Feasibility test (30%) . Function signature: def is feasible (graph, source, sink, flow_value): . Function arguments: graph - a Graph object as specified in Sub-task 1 source - a hashable object, representing the source vertex sink - a hashable object, representing the sink vertex flow_value - a float representing a (potentially infeasible) flow from source to sink. . Return value: a bool which is True if and only if an equal-split flow of flow value units is possible from source to sink.As a simple example, consider the graph in Figure la. If we only had constraints Cl and C2, the maximum flow from vertex 1 to vertex 8 is 4 + 2 + 1 =7. This solution is achieved as follows: . Send 4 units of flow along (D) 2 5 8 . Send 2 units of flow along (1) . Send 1 unit of flow along (1) 4 Adding constraint C3 imposes some level of fairness in the flow. Such a constraint is important in routing packets over the Internet where network operators might want to prevent certain links to be overutilized. Admittedly, the equal-split constraint results in less flow compared to the (unconstrained) maximum flow. In Figure la, the maximum equal-split flow is achieved as follows: . Send 1 unit of flow along . Send 1 unit of flow along . Send 1 unit of flow along (1) This results in a total flow of 3 units from vertex (1) to (8. Despite resulting in a lower value, you shall see that the inclusion of constraint C3 significantly simplifies the problem. Whereas sophisticated algorithms can solve the less constrained problem (using only CI and C2) in O(JV| |E[) time, the maximum equal-split flow (using C1, C2, and C3) can be found quite easily in O(IV| + (E)) time.Input and Output Constraints . All graphs used for checking is guaranteed to be directed and acyclic with (a) 2 f(u,v) = > f(v. w). (The total flow into and out of a vertex must be equal.) (U.")EE (PAW)EE C3: For all pairs of edges (1, v1), (u, v2) E E, f(u, vi) = f(u, v2). (The flow splits evenly between edges from a common verter.) For simplicity, we further assume that all vertices are reachable from s. In this problem, we aim to find an equal-split flow that will maximize the total flow from s (the source) to t (the sink). Overview This machine problem will be implemented in four parts. For each part, you are to write a function which will take a directed acyclic graph G, a source vertex s, and a sink vertex t / s. These functions will answer the following questions: 1. (30%) Does a given flow f satisfy all constraints? 2. (30%) Is it possible to send K > 0 units of flow from s to t? 3. (20%) What is the maximum equal-split flow from s to t? 4. (20%) What is the maximum equal-split flow from s to t if we are allowed to upgrade the capacity of exactly one edge? Illustration 8 (a) (b) (c) (d) Figure 1. Directed acyclic graphs for sample outputsSub-task 3: Maximum equal-split flow (20%) . Function signature: def max equal split_flow(graph, source, sink) : . Function arguments: - graph - a Graph object as specified in Sub-task 1 source - a hashable object, representing the source vertex - sink - a hashable object, representing the sink vertex . Return value: a positive float representing the maximum equal-split flow from source to sink. Sub-task 4: Capacity upgrade (20%) . Function signature: def max_equal_split_flow_upgrade (graph, source, sink) : . Function arguments: graph - a Graph object as specified in Sub-task 1 source - a hashable object, representing the source vertex sink - a hashable object, representing the sink vertex . Return value: a positive float representing the maximum equal-split flow from source to sink after upgrading the capacity of exactly one edge