-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
120 changed files
with
855 additions
and
396 deletions.
There are no files selected for viewing
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
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,56 @@ | ||
using MODA.Impl; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace MODA.Console | ||
{ | ||
public class MODATest | ||
{ | ||
internal static void Run(string[] args) | ||
{ | ||
try | ||
{ | ||
string graphFolder = args[0]; // @"C:\SOMA\Drive\MyUW\Research\Kim\remodaalgorithmimplementation"; | ||
string filename = args[1]; // "QueryGraph.txt"; // "Ecoli20141001CR_idx.txt"; | ||
var dotFileFulllName = Path.Combine(graphFolder, filename); | ||
int subGraphSize = int.Parse(args[2]); | ||
int numIterations = int.Parse(args[3]); | ||
|
||
var sb = new StringBuilder("Processing Graph..."); | ||
sb.AppendFormat("Network File: {0}\nSub-graph Size: {1}\nNumber of Iterations: {2}\n", dotFileFulllName, subGraphSize, numIterations); | ||
sb.AppendLine("==========================================================================\n"); | ||
System.Console.WriteLine(sb); | ||
sb.Clear(); | ||
for (int i = 0; i < numIterations; i++) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
var newGraphInstance = GraphProcessor.LoadGraph(dotFileFulllName); | ||
System.Console.WriteLine("Iteration {0}:\t Network: Nodes - {1}; Edges: {2}\n", (i + 1), newGraphInstance.VertexCount, newGraphInstance.EdgeCount); | ||
|
||
//Visualizer.Visualize(newGraphInstance, dotFileFulllName + ".dot"); | ||
|
||
var frequentSubgraphs = new ModaAlgorithms().Algorithm1(newGraphInstance, subGraphSize); | ||
sw.Stop(); | ||
int totalMappings = 0; | ||
foreach (var queryGraph in frequentSubgraphs) | ||
{ | ||
sb.AppendFormat("\tSub-graph: {0}\t Mappings: {1}\n", queryGraph.Key.AsString(), queryGraph.Value); | ||
totalMappings += queryGraph.Value; | ||
} | ||
sb.AppendFormat("\nTime Taken: {0} ({1}ms)\t Network: Nodes - {2}; Edges: {3}; Total Mappings found: {4}\n", sw.Elapsed.ToString(), sw.ElapsedMilliseconds.ToString("N"), newGraphInstance.VertexCount, newGraphInstance.EdgeCount, totalMappings); | ||
sb.AppendLine("-------------------------------------------\n"); | ||
newGraphInstance = null; | ||
frequentSubgraphs = null; | ||
} | ||
File.WriteAllText(dotFileFulllName + ".puo", sb.ToString()); | ||
} | ||
catch (System.Exception ex) | ||
{ | ||
System.Console.WriteLine(ex); | ||
} | ||
System.Console.WriteLine("Done!"); | ||
System.Console.ReadKey(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,57 +1,11 @@ | ||
using MODA.Impl; | ||
using MODA.Impl.Graphics; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace MODA.Console | ||
namespace MODA.Console | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
try | ||
{ | ||
string graphFolder = args[0]; // @"C:\SOMA\Drive\MyUW\Research\Kim\remodaalgorithmimplementation"; | ||
string filename = args[1]; // "QueryGraph.txt"; // "Ecoli20141001CR_idx.txt"; | ||
var dotFileFulllName = Path.Combine(graphFolder, filename); | ||
int subGraphSize = int.Parse(args[2]); | ||
int numIterations = int.Parse(args[3]); | ||
|
||
var sb = new StringBuilder("Processing Graph..."); | ||
sb.AppendFormat("Network File: {0}\nSub-graph Size: {1}\nNumber of Iterations: {2}\n", dotFileFulllName, subGraphSize, numIterations); | ||
sb.AppendLine("==========================================================================\n"); | ||
System.Console.WriteLine(sb); | ||
sb.Clear(); | ||
for (int i = 0; i < numIterations; i++) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
var newGraphInstance = GraphProcessor.LoadGraph(dotFileFulllName); | ||
System.Console.WriteLine("Iteration {0}:\t Network: Nodes - {1}; Edges: {2}\n", (i + 1), newGraphInstance.VertexCount, newGraphInstance.EdgeCount); | ||
|
||
//Visualizer.Visualize(newGraphInstance, dotFileFulllName + ".dot"); | ||
|
||
var frequentSubgraphs = new ModaAlgorithms().Algorithm1(newGraphInstance, subGraphSize); | ||
sw.Stop(); | ||
int totalMappings = 0; | ||
foreach (var queryGraph in frequentSubgraphs) | ||
{ | ||
sb.AppendFormat("\tSub-graph: {0}\t Mappings: {1}\n", queryGraph.Key.AsString(), queryGraph.Value); | ||
totalMappings += queryGraph.Value; | ||
} | ||
sb.AppendFormat("\nTime Taken: {0} ({1}ms)\t Network: Nodes - {2}; Edges: {3}; Total Mappings found: {4}\n", sw.Elapsed.ToString(), sw.ElapsedMilliseconds.ToString("N"), newGraphInstance.VertexCount, newGraphInstance.EdgeCount, totalMappings); | ||
sb.AppendLine("-------------------------------------------\n"); | ||
newGraphInstance = null; | ||
frequentSubgraphs = null; | ||
} | ||
File.WriteAllText(dotFileFulllName + ".puo", sb.ToString()); | ||
} | ||
catch (System.Exception ex) | ||
{ | ||
System.Console.WriteLine(ex); | ||
} | ||
System.Console.WriteLine("Done!"); | ||
System.Console.ReadKey(); | ||
MODATest.Run(args); | ||
//RecursionHelperTest.Run(); | ||
} | ||
} | ||
} |
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,86 @@ | ||
using MODA.Impl; | ||
using System.Diagnostics; | ||
using System.Threading; | ||
|
||
namespace MODA.Console | ||
{ | ||
public class RecursionHelperTest | ||
{ | ||
public static void Run() | ||
{ | ||
var arr = new[] { 1,5,5,5,5,5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; | ||
RunRecursionHelper(arr); | ||
RunRecursion(arr); | ||
System.Console.ReadKey(); | ||
} | ||
|
||
static void RunRecursion(int[] arr) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
|
||
var ans = Factorial(20); // Sum(arr); | ||
|
||
sw.Stop(); | ||
System.Console.WriteLine("RunRecursion done.\n Time taken: {0}s. Ans = {1}", sw.Elapsed, ans); | ||
} | ||
|
||
static void RunRecursionHelper(int[] arr) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
|
||
var ans = FactorialWithHelper(20); // SumWithHelper(arr); | ||
|
||
sw.Stop(); | ||
System.Console.WriteLine("RunRecursionHelper done.\n Time taken: {0}s. Ans = {1}", sw.Elapsed, ans); | ||
} | ||
|
||
static long Factorial(long n) | ||
{ | ||
//This is the termination condition | ||
if (n < 2) | ||
{ | ||
//This is the returning value when termination condition is true | ||
Thread.Sleep(3000); | ||
return 1; | ||
} | ||
|
||
//This is the recursive call | ||
var fac = Factorial(n - 1); | ||
|
||
//This is the work to do with the current item and the | ||
//result of recursive call | ||
return n * fac; | ||
} | ||
|
||
static long FactorialWithHelper(long n) | ||
{ | ||
return RecursionHelper<long>.CreateSingular(currentParam => currentParam < 2, currentVal => { Thread.Sleep(3000); return 1; }) | ||
.RecursiveCall((currentParam, rv) => currentParam - 1) | ||
.Do((i, rv) => i * rv) | ||
.Execute(n); | ||
} | ||
|
||
static int Sum(int[] array, int index = 0) | ||
{ | ||
//This is the termination condition | ||
if (index >= array.Length) | ||
//This is the returning value when termination condition is true | ||
return 0; | ||
|
||
//This is the recursive call | ||
var sumofrest = Sum(array, index + 1); | ||
|
||
//This is the work to do with the current item and the | ||
//result of recursive call | ||
return array[index] + sumofrest; | ||
} | ||
|
||
static int SumWithHelper(int[] ar) | ||
{ | ||
return RecursionHelper<int>.CreateSingular(i => i >= ar.Length, i => 0) | ||
.RecursiveCall((i, rv) => i + 1) | ||
.Do((i, rv) => ar[i] + rv) | ||
.Execute(0); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.