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

Info iconThis 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, Fnds a sequence of these operations such that after performing the last one, all the edge weights turn positive. Input The Frst row of the input Fle consists of two integers
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background 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

This note was uploaded on 02/06/2011 for the course ECE 423 taught by Professor Dolatabadi during the Spring '11 term at Amirkabir University of Technology.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online