private static ClusterData IsMatch(MatchData matchData, INode firstRoot, INode secondRoot)
{
Side first = matchData.First;
Side second = matchData.Second;
Tuple<Match, Direction> firstFit;
Tuple<Match, Direction> secondFit;
// Cannot match when you have the same root
if (firstRoot == secondRoot)
{
return null;
}
firstFit = IsFit(firstRoot, first.Shred, first);
if (firstFit.Item1 == Match.Impossible)
{
return null;
}
secondFit = IsFit(secondRoot, second.Shred, second);
if (secondFit.Item1 == Match.Impossible)
{
return null;
}
//if (firstFit.Item1 == Match.Inverted && secondFit.Item1 == Match.Inverted)
//{
// return new ClusterData(Match.NonInverted, secondFit.Item2, firstFit.Item2);
//}
//else if (firstFit.Item1 == Match.NonInverted && secondFit.Item1 == Match.NonInverted)
if (firstFit.Item1 == secondFit.Item1)
{
return new ClusterData(Match.NonInverted, firstFit.Item2, secondFit.Item2);
}
else if (firstFit.Item1 == Match.Inverted && secondFit.Item1 == Match.NonInverted ||
firstFit.Item1 == Match.NonInverted && secondFit.Item1 == Match.Inverted)
{
return new ClusterData(Match.Inverted, firstFit.Item2, secondFit.Item2);
}
return null;
}