public bool equals(Object o) { if (this == o) { return(true); } if (o == null || !Object.ReferenceEquals(GetType(), o.GetType())) { return(false); } IndexLowHigh that = (IndexLowHigh)o; if (high != that.high) { return(false); } if (index != that.index) { return(false); } if (low != that.low) { return(false); } return(true); }
public int High(int node) { IndexLowHigh ilh = TDict[node]; if (TDict.TryGetValue(node, out ilh)) { return(ilh.GetHigh()); } return(-1); //Изменить условие и в классе ROBDD }
public int MakeNode(IndexLowHigh ilh) { if (ilh.GetLow().Equals(ilh.GetHigh())) { return(ilh.GetLow()); } else if (hDict.Member(ilh)) { return(hDict.Lookup(ilh)); } else { int node = tDict.Add(ilh); hDict.Insert(ilh, node); return(node); } }
private int RestrictRecursively(int u, int j, bool value) { int index = GettDict().Index(u); if (index == null) { return(u); } else if (index > j) { return(u); } else if (index < j) { int integer = MakeNode(index, RestrictRecursively(GettDict().Low(u), j, value), RestrictRecursively(GettDict().High(u), j, value)); IndexLowHigh ilh = GettDict().Get(u); GethDict().Remove(ilh); GettDict().Remove(u); return(integer); } else { if (!value) { int integer = RestrictRecursively(GettDict().Low(u), j, value); IndexLowHigh ilh = GettDict().Get(u); GethDict().Remove(ilh); GettDict().Remove(u); return(integer); } else { int integer = RestrictRecursively(GettDict().High(u), j, value); IndexLowHigh ilh = GettDict().Get(u); GethDict().Remove(ilh); GettDict().Remove(u); return(integer); } } }
public int MakeNode(int i, int l, int h) { IndexLowHigh ilh = new IndexLowHigh(i, l, h); return(MakeNode(ilh)); }
public void Remove(IndexLowHigh ilh) { HDict.Remove(ilh); }
public int Add(IndexLowHigh data) { TDict.Add(AutoId++, data); return(AutoId - 1); }
public void Insert(int i, int l, int h, int node) { IndexLowHigh ilh = new IndexLowHigh(i, l, h); HDict.Add(ilh, node); }
public void Insert(IndexLowHigh ilh, int node) { HDict.Add(ilh, node); }
public int Lookup(IndexLowHigh ilh) { return(HDict[ilh]); }
public bool Member(IndexLowHigh ilh) { return(HDict.ContainsKey(ilh)); }
private void BuildGraph() { graph.Edges.Clear(); graph.NodeMap.Clear(); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); RobddGraph robddGraph1 = null; realNames = new Dictionary <int, String>(); edge_weight = new Dictionary <int, int>(); BooleanExpression expr = new BooleanExpression(expression); try { robddGraph1 = new RobddGraph(); robddGraph1.Build(expr); Console.WriteLine("ALL SAT"); Console.WriteLine(expr.GetVariableNames()); foreach (BitArray array in robddGraph1.AllSat()) { Console.WriteLine( ConvertBitSetToString(array, expr.GetVariablesCount())); } } catch (Exception e) { Console.WriteLine(e.StackTrace); } TDictionary tDict = robddGraph1.GettDict(); Dictionary <int, IndexLowHigh> dict = tDict.GettDict(); foreach (int node in dict.Keys) { if (node == 0 || node == 1) { //Добавить вершину graph.AddNode(node.ToString()).Attr.Shape = Microsoft.Glee.Drawing.Shape.Box; // GLEE realNames.Add(node, null); } else { IndexLowHigh ilh = dict[node]; int low = ilh.GetLow(); int high = ilh.GetHigh(); int index = ilh.GetIndex(); realNames.Add(node, expr.GetVariableName(index - 1)); int e = edgeFactory.Create(); edge_weight.Add(e, 0); //Добавить ребро graph.AddEdge(node.ToString(), low.ToString()).SourceNode.Attr.Shape = Microsoft.Glee.Drawing.Shape.Circle; e = edgeFactory.Create(); edge_weight.Add(e, 2); //Добавить ребро graph.AddEdge(node.ToString(), high.ToString()).SourceNode.Attr.Shape = Microsoft.Glee.Drawing.Shape.Circle; } } viewer.Graph = graph; //associate the viewer with the form form.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); //show the form form.ShowDialog(); }