[英]C# equivalent for python code maps and lambda
我正在研究 Floyd 和 Warshall 算法,并想使用 LINQ 在 C# 中转换这个 python 片段
def Algorithm(graph):
'''2-D array which stores the graph value'''
dist = map(lambda i : map(lambda j : j , i) , graph)
@sweeper 感谢您的提示。
这是上述代码段的代码块:
public void Algorithm(int[,] graph)
{
int j;
var dist = ((int[,])graph).Cast<int>().ToArray().GroupBy(x => j++ / graph.GetLength(1)).Select(y => y.ToArray()).ToArray();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.