/// <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; }
public PushRelabelMaxFlow(IFlowOperators <W> @operator) { this.@operator = @operator; }
public PushRelabelMaxFlow(IFlowOperators <W> operators) { this.operators = operators; }
public EdmondKarpMaxFlow(IFlowOperators <W> operators) { this.operators = operators; }
public MinCut(IFlowOperators <W> operators) { this.operators = operators; }
public MinCut(IFlowOperators <W> @operator) { this.@operator = @operator; }
public FordFulkersonMaxFlow(IFlowOperators <W> @operator) { this.@operator = @operator; }
public EdmondKarpMaxFlow(IFlowOperators <W> @operator) { this.@operator = @operator; }