예제 #1
0
        /// <summary>
        /// Removes the provided edge form the graph
        /// </summary>
        /// <param name="edge">The edge to be removed</param>
        /// <returns>true if the edge was removed; otherwise false</returns>
        public bool RemoveEdge(IEdge edge)
        {
            bool sourceEdgeRemoved = false;
            bool targetEdgeRemoved = false;

            if (this.type == GraphType.Directed)
            {
                // Ensure the source node exists
                if (this.nodeEdges.Contains(edge.Source))
                {
                    // Get the edge container for the source node
                    EdgeContainer sourceEdges = this[edge.Source];

                    if (sourceEdges != null)
                    {
                        sourceEdgeRemoved = sourceEdges.RemoveEdge(edge);
                    }
                }

                // Ensure that the target node exists
                if (this.nodeEdges.Contains(edge.Target))
                {
                    // Get the edge container for the target node
                    EdgeContainer targetEdges = this[edge.Target];

                    if (targetEdges != null)
                    {
                        targetEdgeRemoved = targetEdges.RemoveEdge(edge);
                    }
                }

                // Verify that the edge was successfully removed
                if (sourceEdgeRemoved || targetEdgeRemoved)
                {
                    // Fire the EdgeRemoved event and decrement edge count
                    OnEdgeRemoved(new EdgeEventArgs(edge, null));
                    this.edgeCount--;

                    // Stop handling the property changed event
                    (edge as Edge).PropertyChanged -= new EventHandler <Common.Events.PropertyChangedEventArgs <object> >(Edge_PropertyChanged);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the EdgeContainer for the specified Node in the current
        /// Berico.LinkANalysis.Model.Graph object.
        /// </summary>
        /// <param name="node">A node in the current Berico.LinkAnalysis.Model.Graph object</param>
        /// <returns>A Berico.LinkAnalysis.Model.EdgeContainer</returns>
        public EdgeContainer this[INode node]
        {
            get
            {
                EdgeContainer edgeContainer = null;

                // Check if the attribute exists
                bool result = this.nodeEdges.Contains(node);

                if (result)
                {
                    // Get the EdgeContainer
                    edgeContainer = (EdgeContainer)this.nodeEdges[node].Value;
                }

                return(edgeContainer);
            }
        }