void SortByTable(FPTransition transition, FPNodeHeadTable nodeTable, ref Queue <FPItem> result) { int size = nodeTable.Size(); for (int i = 0; i < size; ++i) { if (transition.ContainItem(nodeTable.At(i).mOwner)) { result.Enqueue(nodeTable.At(i).mOwner); } } }
void AddNodes(FPTreeNode ancestor, Queue <FPItem> record, FPNodeHeadTable nodeTable) { int size = record.Count; if (size > 0) { FPItem item = record.Dequeue(); FPTreeNode node = item.CreateNode(); node.mCount = 1; node.mParent = ancestor; ancestor.AddChild(node); int count = nodeTable.Size(); FPTreeNode tempNode = null; for (int j = 0; j < count; ++j) { tempNode = nodeTable.At(j); if (tempNode.mName == node.mName) { node.NextNode = tempNode.NextNode; tempNode.NextNode = node; //while (tempNode.NextNode != null) //{ // tempNode = tempNode.NextNode; //} //tempNode.NextNode = node; break; } } AddNodes(node, record, nodeTable); } }
void GenerateProbOne(FPTreeNode root, FPNodeHeadTable table, ref int total) { int size = table.Size(); for (int i = 0; i < size; ++i) { FPTreeNode child = table.At(i); mProbs.Add(child.mName, child.mOwner.mSupport * 1.0f / total); mExistCount.Add(child.mName, child.mOwner.mSupport); } }
void GenerateProbTwo(FPTreeNode root, FPNodeHeadTable table, ref int total) { int size = table.Size(); if (size <= 2) { return; } FPTreeNode childI = null; List <List <FPTreeNode> > calculate = new List <List <FPTreeNode> >(); for (int i = 0; i < size - 1; ++i) { childI = table.At(i); FPTreeNode childJ = null; for (int j = i + 1; j < size; ++j) { List <FPTreeNode> temp = new List <FPTreeNode>(); childJ = table.At(j); temp.Add(childI); temp.Add(childJ); calculate.Add(temp); } } size = calculate.Count; for (int i = 0; i < size; ++i) { FPTreeNode nodeA = calculate[i][0]; FPTreeNode nodeB = calculate[i][1]; int shareCount = CalcuelateSharedCount(nodeA, nodeB); if (shareCount == 0) { continue; } float AB = shareCount * 1.0f / mExistCount[nodeA.mName]; float BA = shareCount * 1.0f / mExistCount[nodeB.mName]; mProbs.Add(nodeA.mName + " " + nodeB.mName, AB); mProbs.Add(nodeB.mName + " " + nodeA.mName, BA); mExistCount.Add(nodeA.mName + " " + nodeB.mName, shareCount); } }
void GenerateProbThree(FPTreeNode root, FPNodeHeadTable table, ref int total) { int size = table.Size(); if (size <= 3) { return; } FPTreeNode childI = null; FPTreeNode childJ = null; FPTreeNode childK = null; List <List <FPTreeNode> > calculate = new List <List <FPTreeNode> >(); for (int i = 0; i < size - 2; ++i) { childI = table.At(i); for (int j = i + 1; j < size - 1; ++j) { childJ = table.At(j); for (int k = j + 1; k < size; ++k) { childK = table.At(k); List <FPTreeNode> temp = new List <FPTreeNode>(); temp.Add(childI); temp.Add(childJ); temp.Add(childK); calculate.Add(temp); } } } size = calculate.Count; for (int i = 0; i < size; ++i) { FPTreeNode nodeA = calculate[i][0]; FPTreeNode nodeB = calculate[i][1]; FPTreeNode nodeC = calculate[i][2]; int shareCount = CalcuelateSharedCount(nodeA, nodeB, nodeC); if (shareCount == 0) { continue; } string ABC = nodeA.mName + " " + nodeB.mName; string ACB = nodeA.mName + " " + nodeC.mName; string BCA = nodeB.mName + " " + nodeC.mName; string BAC = nodeB.mName + " " + nodeA.mName; string CAB = nodeC.mName + " " + nodeA.mName; string CBA = nodeC.mName + " " + nodeB.mName; float abc = shareCount * 1.0f / mExistCount[ABC]; float acb = shareCount * 1.0f / mExistCount[ACB]; float bca = shareCount * 1.0f / mExistCount[BCA]; float bac = shareCount * 1.0f / mExistCount[ABC]; float cab = shareCount * 1.0f / mExistCount[ACB]; float cba = shareCount * 1.0f / mExistCount[BCA]; mProbs.Add(ABC + " " + nodeC.mName, abc); mProbs.Add(ACB + " " + nodeB.mName, acb); mProbs.Add(BCA + " " + nodeA.mName, bca); mProbs.Add(BAC + " " + nodeC.mName, bac); mProbs.Add(CAB + " " + nodeB.mName, cab); mProbs.Add(CBA + " " + nodeA.mName, cba); mExistCount.Add(ABC + " " + nodeC.mName, shareCount); } }