public void CalculatePageRank() { var newPageRankArray = PageRankFactory.CreateEmptyPageRankArray(_graphSize); for (int x = 0; x < _graphSize; x++) { var pageRank = 0.0; for (int y = 0; y < _graphSize; y++) { if (_graph[y][x] == 1) { pageRank += (double)_pageRankArray[y] / GetSum(y); } } newPageRankArray[x] = pageRank; } _pageRankArray = newPageRankArray; }
public void CalculatePageRankParallel() { var newPageRankArray = PageRankFactory.CreateEmptyPageRankArray(_graphSize); Parallel.For(0, _graphSize, x => { var pageRank = 0.0; Parallel.For(0, _graphSize, y => { if (_graph[y][x] == 1) { pageRank += (double)_pageRankArray[y] / GetSum(y); } }); newPageRankArray[x] = pageRank; }); _pageRankArray = newPageRankArray; }
public PageRank(int[][] graph) { _graphSize = graph.Length; _graph = graph; _pageRankArray = PageRankFactory.CreateDefaultPageRankArray(_graphSize); }