ネストされたハッシュセット内でサブセットの複数の組み合わせを見つけなければならないという問題があります。基本的に、「マスター」のネストされたHashSetがあり、「可能な」ネストされたHashSetのコレクションから、「マスター」の同時サブセットである可能性のある「可能性」をプログラムで見つける必要があります。
私が次のものを持っているとしましょう:
var master = new HashSet<HashSet<string>>(new HashSet<string>[] {
new HashSet<string>( new string[] { "A", "B", "C"}),
new HashSet<string>( new string[] { "D", "E"}),
new HashSet<string>( new string[] { "F"})
}
);
var possible1 = new HashSet<HashSet<string>>(new HashSet<string>[] {
new HashSet<string>( new string[] { "A", "B", "C"}),
new HashSet<string>( new string[] { "F"})
}
);
var possible2 = new HashSet<HashSet<string>>(new HashSet<string>[] {
new HashSet<string>( new string[] { "D", "E"})
}
);
var possible3 = new HashSet<HashSet<string>>(new HashSet<string>[] {
new HashSet<string>( new string[] { "F"})
}
);
var possible4 = new HashSet<HashSet<string>>(new HashSet<string>[] {
new HashSet<string>( new string[] { "X", "Y", "Z"})
}
);
var possible5 = new HashSet<HashSet<string>>(new HashSet<string>[] {
new HashSet<string>( new string[] { "A", "B" }),
new HashSet<string>( new string[] { "D", "E"})
}
);
アルゴリズムから取得する必要がある出力は次のようになります。
すべての可能な組み合わせサブセット:
possible1 and possible2
possible3 and possible5
possible2 and possible3
possible1
possible2
possible3
possible5
私はこれにアプローチする最善の方法を見つけようとしています。もちろん、力ずくのオプションもありますが、できればそれを避けようとしています。
私の質問が十分に明確であることを願っています。
編集
サブセットを構成するものをさらに詳しく説明するために、マスター {{"A","B","C"},{"C","D","E",F"},{ "X","Y","Z"}} :
- {{"A","B"}{"C","D"}} は、
- {{"A","B","C"},{"X","Y"}} はサブセットになります
- {{"A","B"},{"A","B"}} はサブセットではありません
- {{"A","B","C","D"}} はサブセットではありません
- {{"A","B","C"},{"C","D","X"}} はサブセットではありません
基本的に、各子セットは、マスター内の対応する子のサブセットである必要があります。