Informatika gyűjtemény

Egy szinttel feljebb Main.java

2004050607080910

NézetNyomtat

Main.java (Vissza)
Az alábbi letöltési lehetőségek közül választhatsz: (segítség)
Karakterkódolás:
Sortörés:
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: utf-8
Méret: 1 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hu.krivan.flow;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Bálint Kriván
 */
public class Main {

    int nodeCount;
    int source;
    int sink;
    int edgeCount;

    public Main() throws FileNotFoundException, IOException {
        BufferedReader input = new BufferedReader(new FileReader("folyam.be"));

        nodeCount = Integer.parseInt(input.readLine());

        String[] sourceAndSink = input.readLine().split(" ");

        source = Integer.parseInt(sourceAndSink[0]) - 1;
        sink = Integer.parseInt(sourceAndSink[1]) - 1;

        Graph g = new Graph(nodeCount, input);
        int[][] flow;

        while (g.hasRoute(source, sink)) {
            // folyam lekérése
            flow = g.getFlow(source, sink);
            // maradék-gráf generálása
            g.makeChangesFromFlow(flow);
        }

        System.out.println(g.getFlowSize());
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            new Main();
        } catch (FileNotFoundException ex) {
            System.out.println("HIBA: Nem található a fájl!");
        } catch (IOException ex) {
            System.out.println("Valamilyen IO hiba!");
        }
    }
}
(Vissza)