public virtual void AddVertex(Vertex v) { v.SetGraph(this); vertexCount++; v.Label = vertexCount.ToString(); vertices.Add(v); matrix.AddVertex(); }
public virtual void RemoveVertex(Vertex v) { int index = vertices.IndexOf(v); bool success = vertices.Remove(v); if (success) { vertexCount--; v.SetGraph(null); //Delete all edges going to and from this vertex foreach (Edge e in v.GetInEdges()) { RemoveEdge(e); } foreach (Edge e in v.GetOutEdges()) { RemoveEdge(e); } matrix.RemoveVertex(index); } }