public void RemoveVertex(object vertexValue) { ModificationStatus status = Vertices.Exists(v => v.Value == vertexValue) ? ModificationStatus.Successful : ModificationStatus.NotExist; VerticesModifiedEventArgs e = new VerticesModifiedEventArgs(status, this[vertexValue]); if (OnRemoveVertex != null) OnRemoveVertex(this, e); if (e.Status == ModificationStatus.Successful) { RemoveAllArcs(vertexValue); Vertices.RemoveAll(v => v.Value == vertexValue); } }
void tree_OnVertexAdded(object sender, VerticesModifiedEventArgs e) { if (e.Status == ModificationStatus.Successful) { if (this._addTo == null) { this.Root = e.Vertex as ITreeNode; } else { this._addTo.AddChild(e.Vertex as ITreeNode); //Add the edge between new vertex and its parent this.AddArc((this._addTo as TreeGraphNode).Value, e.Vertex.Value); } } this._addTo = this.Root; }
public void AddVertex(object vertexValue) { ModificationStatus status = !Vertices.Exists(v => v.Value == vertexValue) ? ModificationStatus.Successful : ModificationStatus.AlreadyExist; VerticesModifiedEventArgs e = new VerticesModifiedEventArgs(status, this[vertexValue]); if (OnAddVertex != null) OnAddVertex(this, e); if (e.Status == ModificationStatus.Successful) Vertices.Add(new Vertex(this, vertexValue)); }
void tree_OnRemoveVertex(object sender, VerticesModifiedEventArgs e) { if (e.Status == ModificationStatus.Successful) { TreeGraphNode tNode = e.Vertex as TreeGraphNode; foreach (TreeGraphNode child in tNode.Children) { this.RemoveVertex(child.Value); } if( !tNode.IsRoot() ) tNode.Parent.Children.Remove(tNode); } }