Skip to content

Commit

Permalink
Generic Math Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kzrnm committed Jun 14, 2022
1 parent 79f0ef6 commit d96f7c1
Show file tree
Hide file tree
Showing 10 changed files with 1,670 additions and 3 deletions.
446 changes: 446 additions & 0 deletions Source/AtCoderLibrary/Graph/MaxFlow.GenericMath.cs

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions Source/AtCoderLibrary/Graph/MaxFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ namespace AtCoder
/// <para>
/// 内部では各辺 e について 2 つの変数、流量 f_e と容量 c_e を管理しています。
/// 頂点 v から出る辺の集合を out(v)、入る辺の集合を in(v)、
/// また頂点 v について g(v, f) = (Σ_in(v) f_e) - (Σ_out(v) f_e) とします。
/// また頂点 v について g(v, f) = (Σ_in(v) f_e) - (Σ_out(v) f_e) とします。
/// </para>
/// </remarks>
#if GENERIC_MATH
[Obsolete("Use generic math")]
#endif
public class MfGraph<TValue, TOp>
where TValue : struct
where TOp : struct, INumOperator<TValue>
Expand Down Expand Up @@ -48,7 +51,7 @@ public MfGraph(int n)
/// 最大容量 <paramref name="cap"/>、流量 0 の辺を追加し、何番目に追加された辺かを返します。
/// </summary>
/// <remarks>
/// 制約:
/// 制約:
/// <list type="bullet">
/// <item>
/// <description>0 ≤ <paramref name="from"/>, <paramref name="to"/> &lt; n</description>
Expand Down
615 changes: 615 additions & 0 deletions Source/AtCoderLibrary/Graph/MinCostFlow.GenericMath.cs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Source/AtCoderLibrary/Graph/MinCostFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ namespace AtCoder
/// <remarks>
/// <para>制約: <typeparamref name="TCap"/>, <typeparamref name="TCost"/> は int, long。</para>
/// </remarks>
#if GENERIC_MATH
[Obsolete("Use generic math")]
#endif
public class McfGraph<TCap, TCapOp, TCost, TCostOp, TCast>
where TCapOp : struct, INumOperator<TCap>
where TCostOp : struct, INumOperator<TCost>
Expand Down
6 changes: 6 additions & 0 deletions Source/AtCoderLibrary/Graph/Wrappers/MaxFlowWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
/// <summary>
/// 最大フロー問題 を解くライブラリ(int版)です。
/// </summary>
#if GENERIC_MATH
[System.Obsolete("Use generic math")]
#endif
public class MfGraphInt : MfGraph<int, IntOperator> { public MfGraphInt(int n) : base(n) { } }

/// <summary>
/// 最大フロー問題 を解くライブラリ(long版)です。
/// </summary>
#if GENERIC_MATH
[System.Obsolete("Use generic math")]
#endif
public class MfGraphLong : MfGraph<long, LongOperator> { public MfGraphLong(int n) : base(n) { } }
}
6 changes: 6 additions & 0 deletions Source/AtCoderLibrary/Graph/Wrappers/MinCostFlowWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace AtCoder
/// <summary>
/// Minimum-cost flow problem を扱うライブラリ(int版)です。
/// </summary>
#if GENERIC_MATH
[System.Obsolete("Use generic math")]
#endif
public class McfGraphInt
: McfGraph<int, IntOperator, int, IntOperator, SameTypeCastOperator<int>>
{
Expand All @@ -15,6 +18,9 @@ public McfGraphInt(int n) : base(n) { }
/// <summary>
/// Minimum-cost flow problem を扱うライブラリ(long版)です。
/// </summary>
#if GENERIC_MATH
[System.Obsolete("Use generic math")]
#endif
public class McfGraphLong
: McfGraph<long, LongOperator, long, LongOperator, SameTypeCastOperator<long>>
{
Expand Down
Loading

0 comments on commit d96f7c1

Please sign in to comment.