/// <summary> /// Returns the union of this DAG with 'other' collection, minus the intersection. /// Note that because the 'other' collection is not necessarilly a DAG, and because we must return a consistent DAG, this will not be the XOR-intersection of sets. /// Instead, the initial union, will need to add all necessary ancestor nodes, and the following subration will remove lots of descendants. /// </summary> /// <param name="other"></param> public void SymmetricExceptWith(ICollection <IGraphNode <NodeDataType> > other) { DAG <NodeDataType> copyOfThis = new DAG <NodeDataType>(_containedNodes); copyOfThis.IntersectWith(other); // This we'll need to remove this intersection from our final union. this.UnionWith(other); this.Remove(copyOfThis); }
/// <summary> /// Takes the intersection of two DAGs. /// This will act like a typical intersection of sets, because both DAGs being intersected are initially consistent. /// </summary> /// <param name="otherDAG"></param> public void IntersectWith(DAG <NodeDataType> otherDAG) { OnDagChange?.Invoke(); // In case someone has subscribed to the changed DAG event. Note that this will fire even if this DAG is unchanged by the intersection. this._containedNodes.IntersectWith(otherDAG._containedNodes); // This assumes that both DAGs are "consistent" in the sense that a node is in a consistent DAG only if all of that node's parents are in the DAG }