cs-page-rank
1.0.1
.NET Framework 4.6.1
Install-Package cs-page-rank -Version 1.0.1
dotnet add package cs-page-rank --version 1.0.1
<PackageReference Include="cs-page-rank" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add cs-page-rank --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: cs-page-rank, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install cs-page-rank as a Cake Addin
#addin nuget:?package=cs-page-rank&version=1.0.1
// Install cs-page-rank as a Cake Tool
#tool nuget:?package=cs-page-rank&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
cs-page-rank
Iterative PageRank implemented in .NET 4.6.1
Install
Install-Package cs-page-rank
Usage
The sample code below shows how to use the page rank to perform link analysis:
using System;
using System.Collections.Generic;
namespace PageRank
{
class Program
{
static void Main(string[] args)
{
PageRankByIterativeMethod();
PageRankByMatrixIterativeMethod();
}
private static void PageRankByIterativeMethod()
{
Random random = new Random();
int pageCount = 1000;
IterativePageRank pr = new IterativePageRank(pageCount);
List<int> pages = new List<int>();
for(int pageId = 0; pageId < pageCount; ++pageId)
{
pages.Add(pageId);
}
for(int fromPageId =0; fromPageId < pageCount; ++fromPageId)
{
int outLinkCount = random.Next(pageCount / 50);
Shuffle(pages, random);
for(int i=0; i < outLinkCount; ++i)
{
int toPageId = pages[i];
pr.AddLink(fromPageId, toPageId);
}
}
double tolerance = 0.00001;
float[] ranks = pr.RankPages(tolerance);
for(int pageId = 0; pageId < 50; ++pageId)
{
Console.WriteLine("Page: {0}, Score: {1}", pageId, ranks[pageId]);
}
}
private static void PageRankByMatrixIterativeMethod()
{
Random random = new Random();
int pageCount = 1000;
MatrixIterativePageRank pr = new MatrixIterativePageRank(pageCount);
List<int> pages = new List<int>();
for (int pageId = 0; pageId < pageCount; ++pageId)
{
pages.Add(pageId);
}
for (int fromPageId = 0; fromPageId < pageCount; ++fromPageId)
{
int outLinkCount = random.Next(pageCount / 50);
Shuffle(pages, random);
for (int i = 0; i < outLinkCount; ++i)
{
int toPageId = pages[i];
pr.AddLink(fromPageId, toPageId);
}
}
double tolerance = 0.00001;
double[] ranks = pr.RankPages(tolerance);
for (int pageId = 0; pageId < 50; ++pageId)
{
Console.WriteLine("Page: {0}, Score: {1}", pageId, ranks[pageId]);
}
}
private static void Shuffle<T>(List<T> a, Random random)
{
int i = 0;
while(i < a.Count)
{
int j = random.Next(i + 1);
Swap(a, i, j);
i++;
}
}
private static void Swap<T>(List<T> a, int i, int j)
{
T temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
Product | Versions |
---|---|
.NET Framework | net461 net462 net463 net47 net471 net472 net48 |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 846 | 5/1/2018 |
Page Rank in .NET 4.6.1