Ejemplo n.º 1
0
        public IEdge AddEdge(IEdge edge)
        {
            if (edge == null)
            {
                throw new ArgumentNullException(nameof(edge));
            }
            if (!Equals(edge.Parent) && !SubGraphs.ContainsKey(edge.Parent))
            {
                throw new ArgumentException(FormattableString.Invariant($"Parent of Edge {edge} not within Graph!"));
            }
            if ((edge.SourceNode == null) || !Nodes.ContainsKey(edge.SourceNode))
            {
                throw new ArgumentException(
                          FormattableString.Invariant($"SourceNode {edge.SourceNode} not within Graph!"));
            }
            if ((edge.EndNode == null) || !Nodes.ContainsKey(edge.EndNode))
            {
                throw new ArgumentException(FormattableString.Invariant($"EndNode {edge.EndNode} not within Graph!"));
            }
            if (!Edges.ContainsKey(edge))
            {
                Edges[edge] = edge;
            }
            var addedEdge = Edges[edge];

            addedEdge.SetAttributes(edge.GetAttributes());
            return(addedEdge);
        }