Esempio n. 1
0
        public static FlowNetwork BuildComplexFlowNetwork()
        {
            Graph g = new Graph();

            g.AddEdge("s", "a");
            g.AddEdge("s", "b");
            g.AddEdge("a", "c");
            g.AddEdge("b", "a");
            g.AddEdge("b", "c");
            g.AddEdge("c", "d");
            g.AddEdge("c", "t");
            g.AddEdge("d", "b");
            g.AddEdge("d", "t");
            var dictC = new Dictionary <EdgeKey, int>();

            dictC[g.GetEdge("s", "a").GetKey()] = 4;
            dictC[g.GetEdge("s", "b").GetKey()] = 8;
            dictC[g.GetEdge("a", "c").GetKey()] = 6;
            dictC[g.GetEdge("b", "a").GetKey()] = 3;
            dictC[g.GetEdge("b", "c").GetKey()] = 6;
            dictC[g.GetEdge("c", "d").GetKey()] = 3;
            dictC[g.GetEdge("c", "t").GetKey()] = 11;
            dictC[g.GetEdge("d", "b").GetKey()] = 1;
            dictC[g.GetEdge("d", "t").GetKey()] = 2;
            var c = FlowNetwork.DictToFlow(dictC);

            return(new FlowNetwork(g, c, "s", "t"));
        }