public override bool TransitiveReduction() { IDictionary <T, HashSet <T> > ancestorNodesLookup = GetAncestorNodesLookup(); if (ancestorNodesLookup is null) { return(false); } foreach (T endNodeId in EndNodes.Select(x => x.Id)) { RemoveRedundantIncomingEdges(endNodeId, ancestorNodesLookup); } return(true); }
public override bool TransitiveReduction() { // For Arrow Graphs only dummy edges need to be reduced. IDictionary <T, HashSet <T> > ancestorNodesLookup = GetAncestorNodesLookup(); if (ancestorNodesLookup is null) { return(false); } foreach (T endNodeId in EndNodes.Select(x => x.Id)) { RemoveRedundantIncomingDummyEdges(endNodeId, ancestorNodesLookup); } return(true); }
public IDictionary <T, HashSet <T> > GetAncestorNodesLookup() { if (!AllDependenciesSatisfied) { return(null); } IList <CircularDependency <T> > circularDependencies = FindStrongCircularDependencies(); if (circularDependencies.Any()) { return(null); } var nodeIdAncestorLookup = new Dictionary <T, HashSet <T> >(); foreach (T endNodeId in EndNodes.Select(x => x.Id)) { HashSet <T> totalAncestorNodes = GetAncestorNodes(endNodeId, nodeIdAncestorLookup); nodeIdAncestorLookup.Add(endNodeId, totalAncestorNodes); } return(nodeIdAncestorLookup); }