示例#1
0
        /// <summary>
        /// Add a new edge to this graph.
        /// Time complexity: O(1).
        /// </summary>
        public void AddOrUpdateEdge(T source, T dest, TW weight, IFlowOperators <TW> flow)
        {
            if (source == null || dest == null)
            {
                throw new ArgumentException();
            }

            if (!Vertices.ContainsKey(source) ||
                !Vertices.ContainsKey(dest))
            {
                throw new Exception("Source or Destination Vertex is not in this graph.");
            }

            if (Vertices[source].OutEdges.TryGetValue(Vertices[dest], out var wOut))
            {
                Vertices[source].OutEdges[Vertices[dest]] = flow.AddWeights(wOut, weight);
            }
            else
            {
                Vertices[source].OutEdges.Add(Vertices[dest], weight);
            }

            if (Vertices[dest].InEdges.TryGetValue(Vertices[source], out var wIn))
            {
                Vertices[dest].InEdges[Vertices[source]] = flow.AddWeights(wIn, weight);
            }
            else
            {
                Vertices[dest].InEdges.Add(Vertices[source], weight);
            }
        }
 public FordFulkersonMaxFlow(IFlowOperators <W> operators)
 {
     this.operators = operators;
 }
示例#3
0
 public PushRelabelMaxFlow(IFlowOperators <W> @operator)
 {
     this.@operator = @operator;
 }
 public PushRelabelMaxFlow(IFlowOperators <W> operators)
 {
     this.operators = operators;
 }
 public EdmondKarpMaxFlow(IFlowOperators <W> operators)
 {
     this.operators = operators;
 }
示例#6
0
 public MinCut(IFlowOperators <W> operators)
 {
     this.operators = operators;
 }
示例#7
0
 public MinCut(IFlowOperators <W> @operator)
 {
     this.@operator = @operator;
 }
示例#8
0
 public FordFulkersonMaxFlow(IFlowOperators <W> @operator)
 {
     this.@operator = @operator;
 }
示例#9
0
 public EdmondKarpMaxFlow(IFlowOperators <W> @operator)
 {
     this.@operator = @operator;
 }