public virtual void RemoveEdge(Relation <T, P> relation) { if (relation == null) { Log.Error("Relation is null."); return; } if (!Edges.Remove(relation)) { Log.Error("Relation is not part of the graph: " + relation); return; } VerticesData[relation.Source].OutEdges.Remove(relation); VerticesData[relation.Target].InEdges.Remove(relation); if (!relation.IsSelfRelation) { recalcIsTree = true; if (!HasParents(relation.Target)) { RootVertices.Add(relation.Target); } } }
public virtual void AddVertex(T vertex) { if (vertex == null) { Log.Error("Vertex is null."); return; } if (VerticesData.ContainsKey(vertex)) { Log.Error("Vertex is already part of the graph: " + vertex); return; } VerticesData[vertex] = new VertexData <T, P>(vertex); recalcIsTree = true; RootVertices.Add(vertex); }