/// <summary> /// Merge two GraphParts through the use of Except operation. /// </summary> /// <param name="p">The other GraphPart</param> public void Except(GraphPart p) { if (p == null) { return; } List<Vertex> forRemoveV = new List<Vertex>(); foreach (Vertex v in innerVertices) { if (p.Vertices.Contains(v)) { forRemoveV.Add(v); } } foreach (Vertex v in forRemoveV) { innerVertices.Remove(v); } List<IEdge> forRemoveE = new List<IEdge>(); foreach (IEdge e in innerEdges) { if (p.Edges.Contains(e)) { forRemoveE.Add(e); } } foreach (IEdge e in forRemoveE) { innerEdges.Remove(e); } }
/// <summary> /// Merge two GraphParts through the use of Union operation. /// </summary> /// <param name="p">The other GraphPart</param> public void Union(GraphPart p) { if (p == null) { return; } foreach (IEdge e in p.Edges) { if (!innerEdges.Contains(e)) { innerEdges.Add(e); } } foreach (Vertex v in p.Vertices) { if (!innerVertices.Contains(v)) { innerVertices.Add(v); } } }
/// <summary> /// Merge two GraphParts through the use of Intersect operation. /// </summary> /// <param name="p">The other GraphPart</param> public void Intersect(GraphPart p) { if (p == null) { return; } List <IEdge> forRemoveE = new List <IEdge>(); foreach (IEdge e in innerEdges) { if (!p.Edges.Contains(e)) { forRemoveE.Add(e); } } foreach (IEdge e in forRemoveE) { innerEdges.Remove(e); } List <Vertex> forRemoveV = new List <Vertex>(); foreach (Vertex v in innerEdges) { if (!p.Vertices.Contains(v)) { forRemoveV.Add(v); } } foreach (Vertex v in forRemoveV) { innerVertices.Remove(v); } }