Пример #1
0
        /// <summary>
        /// Create new edge between two nodes. If the same edge is already contained in this graph, new edge isn't created.
        /// </summary>
        /// <param name="v1">Starting node</param>
        /// <param name="v2">Ending node</param>
        /// <returns> Reference to the added (or finded) edge</returns>
        public override IEdge addEdge(Vertex v1, Vertex v2)
        {
            if (v1 == null || v2 == null)
            {
                return(null);
            }


            IEdge e = new NonOrientedEdge(v1, v2);

            foreach (IEdge edge in innerEdges)
            {
                if (edge.Equals(e))
                {
                    return(null);
                }
            }


            innerEdges.Add(e);

            foreach (var obs in innerEdgeObs)
            {
                obs.update(e, ChangeType.Added);
            }

            return(e);
        }
Пример #2
0
 /// <summary>
 /// Determines whether this two edges are equal.
 /// </summary>
 /// <param name="e">The other edge</param>
 /// <returns>true if unordered sets of node are the same</returns>
 public bool Equals(NonOrientedEdge e)
 {
     if ((this.Vertex_1 == e.Vertex_1 && this.Vertex_2 == e.Vertex_2) || (this.Vertex_1 == e.Vertex_2 && this.Vertex_2 == e.Vertex_1))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #3
0
        /// <summary>
        /// Determines whether this two edges are equal.
        /// </summary>
        /// <param name="obj">The other edge</param>
        /// <returns>true if unordered sets of node are the same </returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            NonOrientedEdge e = obj as NonOrientedEdge;

            if (e == null)
            {
                return(false);
            }

            return(this.Equals(e));
        }
Пример #4
0
        /// <summary>
        /// Create new edge between two nodes. If the same edge is already contained in this graph, new edge isn't created.
        /// </summary>
        /// <param name="v1">Starting node</param>
        /// <param name="v2">Ending node</param>
        /// <returns> Reference to the added (or finded) edge</returns>
        public override IEdge addEdge(Vertex v1, Vertex v2)
        {
            if (v1 == null || v2 == null) { return null; }

            IEdge e = new NonOrientedEdge(v1, v2);
            foreach (IEdge edge in innerEdges)
            {
                if (edge.Equals(e)) { return null; }
            }

            innerEdges.Add(e);

            foreach (var obs in innerEdgeObs)
            {
                obs.update(e, ChangeType.Added);
            }

            return e;
        }
Пример #5
0
 /// <summary>
 /// Determines whether this two edges are equal.
 /// </summary>
 /// <param name="e">The other edge</param>
 /// <returns>true if unordered sets of node are the same</returns>
 public bool Equals(NonOrientedEdge e)
 {
     if ((this.Vertex_1 == e.Vertex_1 && this.Vertex_2 == e.Vertex_2) || (this.Vertex_1 == e.Vertex_2 && this.Vertex_2 == e.Vertex_1)) { return true; }
     else { return false; }
 }