Skip to content

Commit

Permalink
All is well up to this point. The race is now about bringing memory u…
Browse files Browse the repository at this point in the history
…sage down and good successes are being made. Rollback can be to this point
  • Loading branch information
smbadiwe committed Feb 17, 2017
1 parent 79a911a commit 98b5e7c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions MODA.Console/MODATest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ internal static void Run(string[] args)

if (queryGraph == null)
{
ModaAlgorithms.UsingAlgo3 = true;
ModaAlgorithms.BuildTree(subGraphSize);
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion MODA.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static void Main(string[] args)
{
//For args values, see ReadMe.txt
#if DEBUG
args = "../Debug QueryGraph.txt 4 0 y y".Split(' ');
args = "../Debug QueryGraph.txt 4 0 y n".Split(' ');
//args = "../Debug Scere20141001CR_idx.txt 3 0 y n".Split(' '); ../Debug/qg_3v_3e.txt
//args = "../Debug Ecoli20141001CR_idx.txt 4 0 y n".Split(' ');
#else
Expand Down
3 changes: 1 addition & 2 deletions MODA.Impl/Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public sealed class Mapping
public Mapping(Dictionary<string, string> function)
{
Function = function;
InducedSubGraphEdges = new HashSet<Edge<string>>();
}

/// <summary>
Expand All @@ -26,7 +25,7 @@ public Mapping(Dictionary<string, string> function)
/// <summary>
/// All the edges in the input subgraph G that fit the query graph (---Function.Keys)
/// </summary>
public HashSet<Edge<string>> InducedSubGraphEdges { get; private set; }
public HashSet<Edge<string>> InducedSubGraphEdges { get; set; }

/// <summary>
/// Only for when (InducedSubGraph.EdgeCount == currentQueryGraphEdgeCount)
Expand Down
15 changes: 12 additions & 3 deletions MODA.Impl/MappingNodesComparer.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
using System.Collections.Generic;
using System.Linq;

namespace MODA.Impl
{
/// <summary>
/// This compares two <see cref="Mapping"/> nodes are equal. Used in dictionary where these nodes form the key.
/// The node set of interest is that of the mapping images on G; i.e. the set that form the nodes in the Mapping's InducedSubGraph
/// The node set of interest is that of the mapping images on G; i.e. the set that form the nodes in the Mapping's InducedSubGraph.
/// The parameters to be compared are guaranteed to be distinct and of the same length
/// </summary>
public sealed class MappingNodesComparer : EqualityComparer<string[]>
internal sealed class MappingNodesComparer : EqualityComparer<string[]>
{
public override bool Equals(string[] x, string[] y)
{
return new HashSet<string>(x).SetEquals(y);
for (int i = 0; i < x.Length; i++)
{
if (!y.Contains(x[i]))
{
return false;
}
}
return true;
}

public override int GetHashCode(string[] obj)
Expand Down
2 changes: 1 addition & 1 deletion MODA.Impl/ModaAlgorithms.2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal static List<Mapping> Algorithm2(QueryGraph queryGraph, UndirectedGraph<
List<Mapping> mapSet;
if (!theMappings.TryGetValue(key, out mapSet))
{
theMappings[key] = new List<Mapping> { mapping };
theMappings[key] = new List<Mapping> (1) { mapping };
}
else
{
Expand Down
26 changes: 22 additions & 4 deletions MODA.Impl/ModaAlgorithms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class ModaAlgorithms
/// If true, the program will use my modified Grochow's algorithm (Algo 2)
/// </summary>
public static bool UseModifiedGrochow { get; set; }
public static bool UsingAlgo3 { get; set; }

#region Useful mainly for the Algorithm 2 versions

Expand Down Expand Up @@ -78,6 +79,7 @@ private static IList<Mapping> IsomorphicExtension(Dictionary<string, string> par
g_nodes.Add(item.Value);
}
Edge<string> edge_g = null;
HashSet<Edge<string>> inducedSubGraphEdges = new HashSet<Edge<string>>();
var qEdges = queryGraph.Edges;
for (int i = 0; i < subgraphSize - 1; i++)
{
Expand All @@ -90,6 +92,10 @@ private static IList<Mapping> IsomorphicExtension(Dictionary<string, string> par
{
g_nodes.Clear();
h_nodes.Clear();
inducedSubGraphEdges.Clear();
g_nodes = null;
h_nodes = null;
inducedSubGraphEdges = null;
return new Mapping[0];
}
}
Expand All @@ -101,26 +107,38 @@ private static IList<Mapping> IsomorphicExtension(Dictionary<string, string> par
{
if (inputGraph.TryGetEdge(g_nodes[i], g_nodes[j], out edge_g))
{
map.InducedSubGraphEdges.Add(edge_g);
inducedSubGraphEdges.Add(edge_g);
}
}
else
{
if (edge_g != null)
{
map.InducedSubGraphEdges.Add(edge_g);
inducedSubGraphEdges.Add(edge_g);
}
}
}
}
g_nodes.Clear();
h_nodes.Clear();
g_nodes = null;
h_nodes = null;
edge_g = null;
if (queryGraph.EdgeCount > map.InducedSubGraphEdges.Count) // this shouuld never happen; but just in case
if (queryGraph.EdgeCount > inducedSubGraphEdges.Count) // this shouuld never happen; but just in case
{
inducedSubGraphEdges.Clear();
inducedSubGraphEdges = null;
return new Mapping[0];
}

if (UsingAlgo3)
{
map.InducedSubGraphEdges = inducedSubGraphEdges;
}
else
{
inducedSubGraphEdges.Clear();
inducedSubGraphEdges = null;
}
return new List<Mapping>(1) { map };
#endregion

Expand Down

0 comments on commit 98b5e7c

Please sign in to comment.