/// <summary>Adds an edge to the graph.</summary> /// <param name="start">The starting point of the edge.</param> /// <param name="end">The ending point of the edge.</param> public void Add(T start, T end) { if (!_nodes.Contains(start)) { throw new InvalidOperationException("Adding an edge to a graph from a node that does not exists"); } if (!_nodes.Contains(end)) { throw new InvalidOperationException("Adding an edge to a graph to a node that does not exists"); } _edges.Stepper( (Edge e) => throw new InvalidOperationException("Adding an edge to a graph that already exists"), start, start, end, end); _edges.Add(new Edge(start, end)); }
/// <summary>Adds a node to the graph.</summary> /// <param name="node">The node to add to the graph.</param> public void Add(T node) { if (_nodes.Contains(node)) { throw new InvalidOperationException("Adding an already-existing node to a graph"); } _nodes.Add(node); }
public void Neighbors(T a, Step <T> step) { if (!_nodes.Contains(a)) { throw new InvalidOperationException("Attempting to look up the neighbors of a node that does not belong to a graph"); } _edges.Stepper(e => step(e.End), a, a, Omnitree.Bound <T> .None, Omnitree.Bound <T> .None); }