// Compares by distance public static int CompareBaseByDist(NodeDistanceBase in1, NodeDistanceBase in2) { if (in1.distances.Count == 0 && in2.distances.Count == 0) { return(0); } else if (in1.distances.Count == 0) { return(1); } else if (in2.distances.Count == 0) { return(-1); } else if (!in1.BestDist().connected&& in2.BestDist().connected) { return(-1); } else if (!in1.BestDist().connected&& !in2.BestDist().connected&& in1.BestDist().distance < in2.BestDist().distance) { return(-1); } else if (!in1.BestDist().connected&& !in2.BestDist().connected&& in1.BestDist().distance == in2.BestDist().distance) { return(0); } else if (in1.BestDist().connected&& in2.BestDist().connected) { return(0); } return(1); }
// Compares by distance + execeptions public static int CompareExceptBase_old(NodeDistanceBase in1, NodeDistanceBase in2) { int number1 = exceptionNames.FindIndex(el => el == in1.name); int number2 = exceptionNames.FindIndex(el => el == in2.name); if ((number1 >= 0) && (number2 >= 0)) { if (number1 < number2) { return(-1); } return(1); } if ((number1 >= 0) && (in2.name != bestName)) { return(-1); } if ((number2 >= 0) && (in1.name != bestName)) { return(1); } if (in1.name == bestName) { return(-1); } if (in2.name == bestName) { return(1); } return(CompareBaseByDist(in1, in2)); }
private void InitGndVccConts() { int lay = Layers.metal1Trace; if (Params.IsModelBusM2InMiddle()) { lay = Layers.metal2Trace; } ContactSimple busStart = new ContactSimple(Params.leftEdge, Params.VccPosition, lay); ContactSimple busEnd = new ContactSimple(wide - 1, Params.VccPosition, lay); if (processNode.name == Params.GndName) { busStart.y = Params.GndPosition; busEnd.y = Params.GndPosition; } busEnd.SetInOut(); busStart.SetInOut(); processNode.arcCollection.Insert(0, busEnd); processNode.arcCollection.Insert(0, busStart); int idxLast = processNode.arcCollection.Count; NodeDistanceBase dictUnit = new NodeDistanceBase(idxLast, processNode.name); for (int i = 0; i < idxLast; i++) { for (int j = i + 1; j < idxLast; j++) { bool connected = true; bool fixedConnection = false; if (i == 0 && j == 1) { fixedConnection = true; } if (i != j) { dictUnit.AddDistance(i, j, LineStruct.Distance(processNode.arcCollection[i], processNode.arcCollection[j]), connected, fixedConnection); } } } if (idxLast > 1) { nodeDistanceDict.Add(processNode.name, dictUnit); } }
private void InitOneNodeConts() { if (diffusionExcep.FindIndex(el => el == processNode.name) >= 0) { InitGndVccConts(); return; } int idxLast = processNode.arcCollection.Count; NodeDistanceBase dictUnit = new NodeDistanceBase(idxLast, processNode.name); for (int i = 0; i < idxLast; i++) { for (int j = i + 1; j < idxLast; j++) { bool connected = false; bool fixedConnection = false; if (processNode.arcCollection[i].x == processNode.arcCollection[j].x) { connected = true; fixedConnection = true; } if (i != j) { dictUnit.AddDistance(i, j, LineStruct.Distance(processNode.arcCollection[i], processNode.arcCollection[j]), connected, fixedConnection); } } } if (idxLast > 1) { nodeDistanceDict.Add(processNode.name, dictUnit); } }
// Compares by distance + execeptions public static int CompareExceptBase_old(NodeDistanceBase in1, NodeDistanceBase in2) { int number1 = exceptionNames.FindIndex(el => el == in1.name); int number2 = exceptionNames.FindIndex(el => el == in2.name); if ((number1 >= 0) && (number2 >= 0)) { if (number1 < number2) return -1; return 1; } if ((number1 >= 0) && (in2.name != bestName)) return -1; if ((number2 >= 0) && (in1.name != bestName)) return 1; if (in1.name == bestName) return -1; if (in2.name == bestName) return 1; return CompareBaseByDist(in1, in2); }
// Compares by distance public static int CompareBaseByDist(NodeDistanceBase in1, NodeDistanceBase in2) { if (in1.distances.Count == 0 && in2.distances.Count == 0) return 0; else if (in1.distances.Count == 0) return 1; else if (in2.distances.Count == 0) return -1; else if (!in1.BestDist().connected && in2.BestDist().connected) return -1; else if (!in1.BestDist().connected && !in2.BestDist().connected && in1.BestDist().distance < in2.BestDist().distance) return -1; else if (!in1.BestDist().connected && !in2.BestDist().connected && in1.BestDist().distance == in2.BestDist().distance) return 0; else if (in1.BestDist().connected && in2.BestDist().connected) return 0; return 1; }
public NodeDistanceBase(NodeDistanceBase inNodeDist) { distances = new List<NodeDistance>(inNodeDist.distances); name = inNodeDist.name; countNode = new List<int>(inNodeDist.countNode); }
private List<NodeDistanceBase> BoobleSortExcept(List<NodeDistanceBase> inLst) { for (int i = 0; i < inLst.Count; i++) { for (int j = i + 1; j < inLst.Count; j++) { if (NodeDistanceBase.CompareExceptBase(inLst[j], inLst[i]) < 0) { NodeDistanceBase nd = new NodeDistanceBase(inLst[j]); inLst[j] = new NodeDistanceBase(inLst[i]); inLst[i] = nd; } } } return inLst; }
public NodeDistanceBase(NodeDistanceBase inNodeDist) { distances = new List <NodeDistance>(inNodeDist.distances); name = inNodeDist.name; countNode = new List <int>(inNodeDist.countNode); }
private void InitOneNodeConts() { if (diffusionExcep.FindIndex(el => el == processNode.name) >= 0) { InitGndVccConts(); return; } int idxLast = processNode.arcCollection.Count; NodeDistanceBase dictUnit = new NodeDistanceBase(idxLast, processNode.name); for (int i = 0; i < idxLast; i++) { for (int j = i + 1; j < idxLast; j++) { bool connected = false; bool fixedConnection = false; if (processNode.arcCollection[i].x == processNode.arcCollection[j].x) { connected = true; fixedConnection = true; } if (i != j) dictUnit.AddDistance(i, j, LineStruct.Distance(processNode.arcCollection[i], processNode.arcCollection[j]), connected, fixedConnection); } } if (idxLast > 1) nodeDistanceDict.Add(processNode.name, dictUnit); }
private void InitGndVccConts() { int lay = Layers.metal1Trace; if (Params.IsModelBusM2InMiddle()) lay = Layers.metal2Trace; ContactSimple busStart = new ContactSimple(Params.leftEdge, Params.VccPosition, lay); ContactSimple busEnd = new ContactSimple(wide - 1, Params.VccPosition, lay); if (processNode.name == Params.GndName) { busStart.y = Params.GndPosition; busEnd.y = Params.GndPosition; } busEnd.SetInOut(); busStart.SetInOut(); processNode.arcCollection.Insert(0, busEnd); processNode.arcCollection.Insert(0, busStart); int idxLast = processNode.arcCollection.Count; NodeDistanceBase dictUnit = new NodeDistanceBase(idxLast, processNode.name); for (int i = 0; i < idxLast; i++) { for (int j = i + 1; j < idxLast; j++) { bool connected = true; bool fixedConnection = false; if (i == 0 && j == 1) fixedConnection = true; if (i != j) dictUnit.AddDistance(i, j, LineStruct.Distance(processNode.arcCollection[i], processNode.arcCollection[j]), connected, fixedConnection); } } if (idxLast > 1) nodeDistanceDict.Add(processNode.name, dictUnit); }