/// <summary> /// Thransforms this hypergraph to its dual. /// </summary> public void TransformToDual() { AcyclicityInfo aiTmp = ai; ai = aiDual; aiDual = aiTmp; int[][] tmp = vertexList; vertexList = edgeList; edgeList = tmp; }
public AcyclicityInfo Clone() { AcyclicityInfo clone = new AcyclicityInfo(); clone.gamma = (int[])this.gamma.Clone(); clone.R = (int[])this.R.Clone(); clone.betaV = (int[])this.betaV.Clone(); clone.IsAcyclic = this.IsAcyclic; return(clone); }
private void MaxCardinalitySearch() { int noOfVer = vertexList.Length; int noOfEdg = edgeList.Length; ai = new AcyclicityInfo(noOfVer, noOfEdg); int i = noOfVer + 1; int j = 0; // Paper has a 1 based index. // Therefore, initial value is set to -1 instead of 0. int k = -1; int[] alpha = new int[noOfVer]; int[] betaV = ai.betaV; for (int vId = 0; vId < noOfVer; vId++) { alpha[vId] = -1; } EdgeSets sets = new EdgeSets(noOfEdg, noOfVer); int[] R = ai.R; int[] size = new int[noOfEdg]; int[] betaE = new int[noOfEdg]; int[] gamma = ai.gamma; for (int S = 0; S < noOfEdg; S++) { gamma[S] = -1; } while (j >= 0) { int S = sets.Remove(j); k++; betaE[S] = k; R[k] = S; size[S] = -1; foreach (int vId in edgeList[S]) { if (alpha[vId] >= 0) { continue; } i--; alpha[vId] = i; betaV[vId] = k; foreach (int eId in vertexList[vId]) { if (size[eId] < 0) { continue; } gamma[eId] = k; sets.Remove(eId, size[eId]); size[eId]++; if (size[eId] < edgeList[eId].Length) { sets.Add(eId, size[eId]); } else if (size[eId] == edgeList[eId].Length) { size[eId] = -1; } } // foreach eId } // foreach vId // In paper: j++ j = edgeList[S].Length; while (j >= 0 && sets.Size(j) == 0) { j--; } } }