グラフ内のノード要素のリストのパワーセットを生成しようとしています。以前の投稿 (セットのユニークな組み合わせ)から次のコードを特定して適応させました。
Public Function PowerSet(ByVal s As List(Of Node)) As List(Of List(Of Node))
Dim ini As List(Of List(Of Node)) = New List(Of List(Of Node))
Return s.Aggregate(ini, Function(a, b) a.Concat(a.Select(Function(x) x.Concat({b}))))
End Function
を使用して機能をテストしています
For Each x In G.PowerSet(G.internal_nodes_in_path)
Console.WriteLine(x)
Next
ただし、PowerSet 関数の関数 (a,b) を指す無効なキャスト例外エラーが発生します。
追加情報: タイプ 'WhereSelectListIterator 2[System.Collections.Generic.List
1[cDAG_with_classes.Node],System.Collections.Generic.IEnumerable 1[cDAG_with_classes.Node]]' to type 'System.Collections.Generic.IEnumerable
1[System.Collections.Generic.List`1[cDAG_with_classes.Node]]' のオブジェクトをキャストできません。
私が間違っている可能性がある場所について、誰かアドバイスをいただけますか?
ありがとう