Skip to content

Commit

Permalink
All is still well up to this point, even though memory usage is still…
Browse files Browse the repository at this point in the history
… bad. Roll-back can be up to this point.
  • Loading branch information
smbadiwe committed Feb 15, 2017
1 parent 5da0cff commit 3e8f6c1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 49 deletions.
21 changes: 4 additions & 17 deletions MODA.Impl/ModaAlgorithms.2.Modified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static List<Mapping> Algorithm2_Modified(QueryGraph queryGraph, Undirect

H_NodeNeighbours = new Dictionary<string, HashSet<string>>();
G_NodeNeighbours = new Dictionary<string, HashSet<string>>();
var theMappings = new Dictionary<string[], List<Mapping>>(new MappingNodesComparer());
var theMappings = new Dictionary<string[], Mapping>(new MappingNodesComparer());
var inputGraphDegSeq = inputGraph.GetDegreeSequence(numberOfSamples);

Console.WriteLine("Calling Algo 2-Modified: Number of Iterations: {0}.\n", numberOfSamples);
Expand Down Expand Up @@ -60,22 +60,9 @@ private static List<Mapping> Algorithm2_Modified(QueryGraph queryGraph, Undirect
Mapping mapping = mappings[k];
//Recall: f(h) = g
var key = mapping.Function.Values.ToArray();
//var key = mapping.InducedSubGraph.Vertices.ToArray();
List<Mapping> mappingsToSearch;
//if (theMappings.TryGetValue(key, out mappingsToSearch))
//{
// if (false == mappingsToSearch.Exists(x => x.IsIsomorphicWith(mapping, queryGraph)))
// {
// theMappings[key].Add(mapping);
// }
//}
//else
//{
// theMappings[key] = new List<Mapping> { mapping };
//}
if (!theMappings.TryGetValue(key, out mappingsToSearch))
if (!theMappings.ContainsKey(key))
{
theMappings[key] = new List<Mapping> { mapping };
theMappings[key] = mapping;
}
}

Expand All @@ -91,7 +78,7 @@ private static List<Mapping> Algorithm2_Modified(QueryGraph queryGraph, Undirect
var toReturn = new List<Mapping>();
foreach (var mapping in theMappings)
{
toReturn.AddRange(mapping.Value);
toReturn.Add(mapping.Value);
}
//InputSubgraphs = null;
inputGraphDegSeq.Clear();
Expand Down
22 changes: 5 additions & 17 deletions MODA.Impl/ModaAlgorithms.2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ internal static List<Mapping> Algorithm2(QueryGraph queryGraph, UndirectedGraph<
// We do need it.

H_NodeNeighbours = new Dictionary<string, HashSet<string>>();
var theMappings = new Dictionary<string[], List<Mapping>>(new MappingNodesComparer());
//var theMappings = new Dictionary<string[], List<Mapping>>(new MappingNodesComparer());
var theMappings = new Dictionary<string[], Mapping>(new MappingNodesComparer());
var inputGraphDegSeq = inputGraphClone.GetDegreeSequence(numberOfSamples);
var queryGraphVertices = queryGraph.Vertices.ToArray();
var subgraphSize = queryGraphVertices.Length;
Expand Down Expand Up @@ -56,22 +57,9 @@ internal static List<Mapping> Algorithm2(QueryGraph queryGraph, UndirectedGraph<
Mapping mapping = mappings[k];
//Recall: f(h) = g
var key = mapping.Function.Values.ToArray();
//var key = mapping.InducedSubGraph.Vertices.ToArray();
List<Mapping> mappingsToSearch;
//if (theMappings.TryGetValue(key, out mappingsToSearch))
//{
// if (false == mappingsToSearch.Exists(x => x.IsIsomorphicWith(mapping, queryGraph)))
// {
// theMappings[key].Add(mapping);
// }
//}
//else
//{
// theMappings[key] = new List<Mapping> { mapping };
//}
if (!theMappings.TryGetValue(key, out mappingsToSearch))
if (!theMappings.ContainsKey(key))
{
theMappings[key] = new List<Mapping> { mapping };
theMappings[key] = mapping;
}
}

Expand All @@ -92,7 +80,7 @@ internal static List<Mapping> Algorithm2(QueryGraph queryGraph, UndirectedGraph<
var toReturn = new List<Mapping>();
foreach (var mapping in theMappings)
{
toReturn.AddRange(mapping.Value);
toReturn.Add(mapping.Value);
}
//Console.WriteLine("\nAlgorithm 2: All iteration tasks completed. Number of mappings found: {0}.\n", toReturn.Count);
//timer.Stop();
Expand Down
35 changes: 20 additions & 15 deletions MODA.Impl/ModaAlgorithms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static IList<Mapping> IsomorphicExtension(Dictionary<string, string> par
}
return listOfIsomorphisms;
}

/// <summary>
/// If there is a neighbor d ∈ D of m such that n is NOT neighbors with f(d),
/// or if there is a NON-neighbor d ∈ D of m such that n is neighbors with f(d)
Expand All @@ -147,15 +147,17 @@ private static bool IsNeighbourIncompatible(UndirectedGraph<string, Edge<string>
}

//If there is a neighbor d ∈ D of m such that n is NOT neighbors with f(d),
string val; // f(d)
var neighboursOfN = inputGraph.GetNeighbors(n, true);

//bool doNext = false;
string val; // f(d)
foreach (var d in neighborsOfM)
{
if (!partialMap.TryGetValue(d, out val))
{
neighboursOfN = null;
return false;
//doNext = true;
//break;
}
if (!neighboursOfN.Contains(val))
{
Expand All @@ -165,25 +167,28 @@ private static bool IsNeighbourIncompatible(UndirectedGraph<string, Edge<string>
}

//// or if there is a NON - neighbor d ∈ D of m such that n IS neighbors with f(d)
//var nonNeighborOfM = queryGraph.Vertices.Except(neighborsOfM);
//foreach (var d in nonNeighborOfM)
//if (doNext)
//{
// if (!partialMap.TryGetValue(d, out val))
// var nonNeighborOfM = queryGraph.Vertices.Except(neighborsOfM);
// foreach (var d in nonNeighborOfM)
// {
// neighboursOfN = null;
// return false;
// }
// if (neighboursOfN.Contains(val))
// {
// neighboursOfN = null;
// return true;
// if (!partialMap.TryGetValue(d, out val))
// {
// neighboursOfN = null;
// return false;
// }
// if (neighboursOfN.Contains(val))
// {
// neighboursOfN = null;
// return true;
// }
// }
// nonNeighborOfM = null;
//}
//nonNeighborOfM = null;
neighboursOfN = null;
return false;
}

///// <summary>
/////
///// </summary>
Expand Down

0 comments on commit 3e8f6c1

Please sign in to comment.