public BinaryTreeNode BUILD_META_TREE(BinaryTreeNode bdd, LeafNode leaf) { BinaryTreeNode P, P10, P1, P0, _P10, P_left; P = new BinaryTreeNode(); if (leaf != null) { if (bdd.Node_Num == leaf.Node_Num) { P.flag = 1; P.Node_Num = bdd.Node_Num; P.Data = "p" + P.Node_Num.ToString(); P10 = ToolFunction.APPLY(1, bdd.Left, bdd.Right); P10 = SIMPLIFY(P10); P.Right = BUILD_META_TREE(P10, leaf.Next); // _P10=BUILD_META_TREE(P10,NULL); _P10 = ToolFunction.OPPOSE(P.Right); P_left = new BinaryTreeNode(); P_left.flag = 2; P_left.Node_Num = bdd.Node_Num; P_left.Data = "q" + P_left.Node_Num.ToString(); P1 = BUILD_META_TREE(bdd.Left, leaf.Next); // P_left->LEFT_CHILD=APPLY(1,P1,_P10); P_left.Left = SIMPLIFY(ToolFunction.APPLY(1, P1, _P10)); P0 = BUILD_META_TREE(bdd.Right, leaf.Next); // P_left->RIGHT_CHILD=APPLY(1,P0,_P10); P_left.Right = SIMPLIFY(ToolFunction.APPLY(1, P0, _P10)); P.Left = P_left; } else { P.flag = 1; P.Node_Num = leaf.Node_Num; P.Data = "p" + P.Node_Num.ToString(); P_left = new BinaryTreeNode(); P_left.flag = 0; P_left.Node_Num = 0; P_left.Data = P_left.Node_Num.ToString(); P_left.Left = P_left.Right = null; P.Left = P_left; P.Right = BUILD_META_TREE(bdd, leaf.Next); } } else { if (bdd.Node_Num == 0 || bdd.Node_Num == 1) { P.flag = 0; P.Node_Num = bdd.Node_Num; P.Data = P.Node_Num.ToString(); P.Left = P.Right = null; } } SIMPLIFY(P); return(P); }
public BinaryTreeNode FAT_BDD(FaultTreeNode FAT) { if (FAT.Node_Type == 0) { BinaryTreeNode BDD, left, right; BDD = new BinaryTreeNode(); left = new BinaryTreeNode(); right = new BinaryTreeNode(); BDD.Node_Num = FAT.Node_Num; BDD.Data = FAT.Node_Num.ToString(); left.Node_Num = 1; left.Data = "1"; right.Node_Num = 0; right.Data = "0"; BDD.Left = left; BDD.Right = right; return(BDD); } FaultTreeNode p, q; q = FAT.Child; p = q.Sibling; BinaryTreeNode itep, iteq; iteq = FAT_BDD(q); while (p != null) { itep = FAT_BDD(p); iteq = ToolFunction.APPLY(FAT.Gate_Type, iteq, itep); p = p.Sibling; } if (FAT.Gate_Type == 3) { iteq = ToolFunction.OPPOSE(iteq); } return(iteq); }