{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ca02 - | V | | E | the former is the number of vertices and...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
In the Name of God Fall 2005 Discrete Mathematics Computer Assignment 2 Due: Azar 30 Suppose that G = ( V, E ) is a directed graph. Each edge of the graph, ( i, j ) , connecting vertex i to vertex j , has a weight which is an integer value. Consider v V and all its adjacent edges. The operation Transfer(v,d) is performed when the weights of all the incoming edges to vertex v are decremented by an integer value d , and that of all the outgoing edges from this vertex are incremented by d . We want to perform a sequence of these operations in a way that all the edge weights become positive. Write a program that, given a graph G and its edge weights, finds a sequence of these operations such that after performing the last one, all the edge weights turn positive. Input The first row of the input file consists of two integers
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: | V | , | E | ; the former is the number of vertices and the latter is the number of edges. Each of the following | E | rows denotes a single edge. In each of these lines, there are three integers; the Frst is the source vertex, the second is the target vertex and the third is the edge weight. You can suppose that the graph is simple and it consists of at most 100 vertices. Output Each row of the output Fle contains integers v, d , which denotes the operation Transfer(v,d) . If there is no solution to the given graph, the output should contain the single string “NO SOLUTION”. Sample Input 4 5 2 3 4 4 2 5 3 4 2 3 1 0 1 2 -1 1 Output for Sample Input 3 3 1 2 2...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern