-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ec1fb9
commit faaf9d7
Showing
69 changed files
with
1,348 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using GetOneHopNode; | ||
using System.Collections; | ||
|
||
namespace Brute_force1 | ||
{ | ||
|
||
class Program2 | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
KeyValuePair<string, UInt64> node1; | ||
KeyValuePair<string, UInt64> node2; | ||
// ///一跳测试 | ||
// ///id--id | ||
// node1 = new KeyValuePair<string, UInt64>("Id", 2140251882); | ||
// node2 = new KeyValuePair<string, UInt64>("Id", 2143554828); | ||
// Solution2.solve(node1, node2); | ||
// ///id--AA.AuId | ||
// node1 = new KeyValuePair<string, UInt64>("Id", 2140251882); | ||
// node2 = new KeyValuePair<string, UInt64>("AA.AuId", 2145115012); | ||
// Solution2.solve(node1, node2); | ||
// ///AA.AuId--id | ||
// node1 = new KeyValuePair<string, UInt64>("AA.AuId", 2145115012); | ||
// node2 = new KeyValuePair<string, UInt64>("Id", 2140251882); | ||
// Solution2.solve(node1, node2); | ||
// ///AA.AuId--AA.AuId | ||
// node1 = new KeyValuePair<string, UInt64>("AA.AuId", 2145115012); | ||
// node2 = new KeyValuePair<string, UInt64>("AA.AuId", 2145115015); | ||
///id to id 1970381522 to 2162351023 大家算出来多少? 36 | ||
///[id, AA.AuId]=[2273736245,2094437628]有多少对啊? 41 19 | ||
///大家看看这组数据有多少边,我这里出来2584条,感觉有点虚:2126125555,2153635508 | ||
///两跳测试 | ||
///id--id | ||
node1 = new KeyValuePair<string, UInt64>("Id", 2126125555); | ||
node2 = new KeyValuePair<string, UInt64>("Id", 2153635508); | ||
Solution2.solve(node1, node2); | ||
|
||
Console.ReadLine(); | ||
} | ||
} | ||
class Solution2 | ||
{ | ||
private class SortedSetComparer : IComparer<KeyValuePair<string, UInt64>> | ||
{ | ||
public int Compare(KeyValuePair<string, UInt64> x, KeyValuePair<string, UInt64> y) | ||
{ | ||
if (x.Key != y.Key) | ||
return x.Key.CompareTo(y.Key); | ||
else | ||
return x.Value.CompareTo(y.Value); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// pair比较函数,小于号 | ||
/// </summary> | ||
/// <param name="o1">操作数1</param> | ||
/// <param name="o2">操作数2</param> | ||
/// <returns></returns> | ||
public static SortedSet<KeyValuePair<string, UInt64>> GetOneHopNode(KeyValuePair<string, UInt64> nodeid) | ||
{ | ||
//通过id获取one-hop节点集合 | ||
SortedSet<KeyValuePair<string, UInt64>> retval; | ||
/* | ||
* 这里是获取id 的过程,基本上需要两步,第一步通过id获取该id的属性, | ||
* 第二步通过属性获取有此属性的一跳节点id集合 | ||
*/ | ||
/* | ||
* 获取1-Hop的node list | ||
* by Esdreal | ||
*/ | ||
GetOneHopNodeClass getOneHop = new GetOneHopNodeClass(); | ||
retval = getOneHop.getNode(nodeid); | ||
return retval; | ||
} | ||
public static Dictionary<KeyValuePair<string, UInt64>, SortedSet<KeyValuePair<string, UInt64>>> GetTwoHopNode(SortedSet<KeyValuePair<string, UInt64>> hop1set) | ||
{ | ||
Dictionary<KeyValuePair<string, UInt64>, SortedSet<KeyValuePair<string, UInt64>>> dic = new Dictionary<KeyValuePair<string, ulong>, SortedSet<KeyValuePair<string, ulong>>>(); | ||
//通过id获取one-hop节点集合 | ||
long start, end; | ||
foreach (KeyValuePair<string, UInt64> nodeid in hop1set) | ||
{ | ||
///Console.WriteLine("find:{0}:{1}", nodeid.Key, nodeid); | ||
start = DateTime.Now.Ticks; | ||
GetOneHopNodeClass getOneHop = new GetOneHopNodeClass(); | ||
SortedSet<KeyValuePair<string, UInt64>> tmp=getOneHop.getNode(nodeid); | ||
end = DateTime.Now.Ticks; | ||
/// Console.WriteLine("{0}:获取hop1set花费时间", (end - start) / 1000); | ||
dic.Add(nodeid, tmp); | ||
} | ||
return dic; | ||
} | ||
/// <summary> | ||
/// </summary> | ||
/// <param name="node1">节点1</param> | ||
/// <param name="node2">节点2</param> | ||
public static void solve(KeyValuePair<string, UInt64> node1, KeyValuePair<string, UInt64> node2) | ||
{ | ||
long count = 0; | ||
long start, end; | ||
///step1:获取node1和node2是否存在一跳关系 | ||
start = DateTime.Now.Ticks; | ||
SortedSet <KeyValuePair<string, UInt64>> hop1set = GetOneHopNode(node1); | ||
end = DateTime.Now.Ticks; | ||
Console.WriteLine("时间{0}:set大小:{1}",(end-start)/1000000, hop1set.ToList().Capacity); | ||
if (!(node1.Key.Equals("AA.AuId") && node2.Key.Equals("AA.AuId"))) | ||
{ | ||
///当两个节点都是AA.AuId时,不可能存在一跳关系 | ||
if (hop1set.Contains<KeyValuePair<string, UInt64>>(node2) == true) | ||
{ | ||
//存在one-hop | ||
Console.WriteLine("{0}:存在one-hop", count++); | ||
Console.WriteLine("[{0},{1}]", node1, node2); | ||
} | ||
} | ||
///step2:获取两跳关系 | ||
start = DateTime.Now.Ticks; | ||
Dictionary<KeyValuePair<string, UInt64>, SortedSet<KeyValuePair<string, UInt64>>> hop2dic = GetTwoHopNode(hop1set); | ||
SortedSet<KeyValuePair<string, UInt64>> hop2set = new SortedSet<KeyValuePair<string, ulong>>(new SortedSetComparer()); | ||
foreach (KeyValuePair<KeyValuePair<string, UInt64>, SortedSet<KeyValuePair<string, UInt64>>> kv in hop2dic) | ||
{ | ||
foreach (KeyValuePair<string, UInt64> tmppair in kv.Value) | ||
hop2set.Add(tmppair); | ||
if (kv.Value.Contains(node2)) | ||
{ | ||
Console.WriteLine("{0}:存在two-hop", count++); | ||
Console.WriteLine("[{0},{1},{2}]", node1,kv.Key, node2); | ||
} | ||
} | ||
|
||
end = DateTime.Now.Ticks; | ||
Console.WriteLine("时间{0}:set大小:{1}", (end - start) / 1000000, hop2set.ToList().Capacity); | ||
//step3:获取三跳关系 | ||
start = DateTime.Now.Ticks; | ||
Dictionary<KeyValuePair<string, UInt64>, SortedSet<KeyValuePair<string, UInt64>>> hop3dic = GetTwoHopNode(hop2set); | ||
SortedSet<KeyValuePair<string, UInt64>> hop3set = new SortedSet<KeyValuePair<string, ulong>>(new SortedSetComparer()); | ||
foreach (KeyValuePair<KeyValuePair<string, UInt64>, SortedSet<KeyValuePair<string, UInt64>>> kv in hop3dic) | ||
{ | ||
hop3set.Union(kv.Value); | ||
if (kv.Value.Contains(node2)) | ||
{ | ||
Console.WriteLine("{0}:存在three-hop", count++); | ||
Console.WriteLine("[{0},{1},{2}]", node1, kv.Key, node2); | ||
} | ||
|
||
} | ||
end = DateTime.Now.Ticks; | ||
Console.WriteLine("时间{0}:set大小:{1}", (end - start) / 1000000, hop3set.ToList().Capacity); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
</assembly> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
Brute-force1/obj/Debug/Brute-force1.csproj.FileListAbsolute.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
I:\github\tmpqts\Brute-force1\bin\Debug\Brute-force1.exe.config | ||
I:\github\tmpqts\Brute-force1\bin\Debug\Brute-force1.exe | ||
I:\github\tmpqts\Brute-force1\bin\Debug\Brute-force1.pdb | ||
I:\github\tmpqts\Brute-force1\bin\Debug\GetOneHopNode.dll | ||
I:\github\tmpqts\Brute-force1\bin\Debug\magApiCs.dll | ||
I:\github\tmpqts\Brute-force1\bin\Debug\GetOneHopNode.pdb | ||
I:\github\tmpqts\Brute-force1\bin\Debug\magApiCs.pdb | ||
I:\github\tmpqts\Brute-force1\obj\Debug\Brute-force1.csprojResolveAssemblyReference.cache | ||
I:\github\tmpqts\Brute-force1\obj\Debug\Brute-force1.exe | ||
I:\github\tmpqts\Brute-force1\obj\Debug\Brute-force1.pdb |
Binary file added
BIN
+10.6 KB
Brute-force1/obj/Debug/Brute-force1.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.59 KB
Brute-force1/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.54 KB
GetOneHopNode/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
GetOneHopNode/obj/Debug/GetOneHopNode.csproj.FileListAbsolute.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
I:\github\tmpqts\GetOneHopNode\bin\Debug\GetOneHopNode.dll | ||
I:\github\tmpqts\GetOneHopNode\bin\Debug\GetOneHopNode.pdb | ||
I:\github\tmpqts\GetOneHopNode\bin\Debug\magApiCs.dll | ||
I:\github\tmpqts\GetOneHopNode\bin\Debug\magApiCs.pdb | ||
I:\github\tmpqts\GetOneHopNode\obj\Debug\GetOneHopNode.csprojResolveAssemblyReference.cache | ||
I:\github\tmpqts\GetOneHopNode\obj\Debug\GetOneHopNode.dll | ||
I:\github\tmpqts\GetOneHopNode\obj\Debug\GetOneHopNode.pdb |
Binary file added
BIN
+7.86 KB
GetOneHopNode/obj/Debug/GetOneHopNode.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file added
BIN
+6.6 KB
GetOneHopNodeTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file added
BIN
+6.62 KB
GetOneHopNodeTestAsync/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> | ||
<security> | ||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
</assembly> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
I:\github\tmpqts\magApiCs\bin\Debug\magApiCs.dll | ||
I:\github\tmpqts\magApiCs\bin\Debug\magApiCs.pdb | ||
I:\github\tmpqts\magApiCs\obj\Debug\magApiCs.csprojResolveAssemblyReference.cache | ||
I:\github\tmpqts\magApiCs\obj\Debug\magApiCs.dll | ||
I:\github\tmpqts\magApiCs\obj\Debug\magApiCs.pdb |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
<ProjectGuid>{AF931A15-2C11-42CF-8FCB-9F12F1BE1E23}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<NoStandardLibraries>false</NoStandardLibraries> | ||
<AssemblyName>ConsoleApplication</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<PlatformTarget>x86</PlatformTarget> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<PlatformTarget>x86</PlatformTarget> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<RootNamespace>ympqts</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include=".gitattributes" /> | ||
<Content Include=".gitignore" /> | ||
<Content Include="magApiPython\magApiPython.py" /> | ||
<Content Include="restServer\restServer.csproj" /> | ||
<Content Include="restServer\Service1.svc" /> | ||
<Content Include="新建文本文档.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="magApiPython\magApiPython.pyproj" /> | ||
<None Include="restServer\Web.config" /> | ||
<None Include="restServer\Web.Debug.config" /> | ||
<None Include="restServer\Web.Release.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="restServer\IService1.cs" /> | ||
<Compile Include="restServer\Properties\AssemblyInfo.cs" /> | ||
<Compile Include="restServer\Service1.svc.cs"> | ||
<DependentUpon>Service1.svc</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include=".git\" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" /> | ||
<ProjectExtensions> | ||
<VisualStudio AllowExistingFolder="true" /> | ||
</ProjectExtensions> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25123.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ympqts", "ympqts.csproj", "{AF931A15-2C11-42CF-8FCB-9F12F1BE1E23}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x86 = Debug|x86 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AF931A15-2C11-42CF-8FCB-9F12F1BE1E23}.Debug|x86.ActiveCfg = Debug|x86 | ||
{AF931A15-2C11-42CF-8FCB-9F12F1BE1E23}.Debug|x86.Build.0 = Debug|x86 | ||
{AF931A15-2C11-42CF-8FCB-9F12F1BE1E23}.Release|x86.ActiveCfg = Release|x86 | ||
{AF931A15-2C11-42CF-8FCB-9F12F1BE1E23}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Empty file.