Beispiel #1
0
        /// <summary>
        /// Adds an <see cref="Edge" /> to the subgraph.
        /// The associated <see cref="DirectedEdge" />s and <see cref="Node" />s are also added.
        /// </summary>
        /// <param name="e">The <see cref="Edge" /> to add.</param>
        public void Add(Edge e)
        {                        
            if (edges.Contains(e))  
                return;

            edges.Add(e);

            dirEdges.Add(e.GetDirEdge(0));
            dirEdges.Add(e.GetDirEdge(1));
            
            nodeMap.Add(e.GetDirEdge(0).FromNode);
            nodeMap.Add(e.GetDirEdge(1).FromNode);            
        }
Beispiel #2
0
 /// <summary>
 /// Adds the Edge and its DirectedEdges with this PlanarGraph.
 /// Assumes that the Edge has already been created with its associated DirectEdges.
 /// Only subclasses can add Edges, to ensure the edges added are of the right class.
 /// </summary>
 /// <param name="edge"></param>
 protected void Add(Edge edge)
 {
     edges.Add(edge);
     Add(edge.GetDirEdge(0));
     Add(edge.GetDirEdge(1));
 }
Beispiel #3
0
 /// <summary>
 /// Removes an Edge and its associated DirectedEdges from their from-Nodes and
 /// from this PlanarGraph. Note: This method does not remove the Nodes associated
 /// with the Edge, even if the removal of the Edge reduces the degree of a
 /// Node to zero.
 /// </summary>
 /// <param name="edge"></param>
 public void Remove(Edge edge)
 {
     Remove(edge.GetDirEdge(0));
     Remove(edge.GetDirEdge(1));
     edges.Remove(edge);
     edge.Remove();
 }
 /// <summary>
 /// Returns the zero-based index of the given Edge, after sorting in ascending order
 /// by angle with the positive x-axis.
 /// </summary>
 /// <param name="edge"></param>
 /// <returns></returns>
 public int GetIndex(Edge edge)
 {
     SortEdges();
     for (int i = 0; i < outEdges.Count; i++)
     {
         DirectedEdge de = (DirectedEdge)outEdges[i];
         if (de.Edge == edge)
             return i;
     }
     return -1;
 }
Beispiel #5
0
 /// <summary>
 /// Returns the zero-based index of the given Edge, after sorting in ascending order
 /// by angle with the positive x-axis.
 /// </summary>
 /// <param name="edge"></param>
 /// <returns></returns>
 public int GetIndex(Edge edge)
 {
     return deStar.GetIndex(edge);
 }
Beispiel #6
0
 /// <summary>
 /// Tests whether an <see cref="Edge" /> is contained in this subgraph.
 /// </summary>
 /// <param name="e">The <see cref="Edge" /> to test.</param>
 /// <returns><c>true</c> if the <see cref="Edge" /> is contained in this subgraph.</returns>
 public bool Contains(Edge e) 
 { 
     return edges.Contains(e); 
 }
Beispiel #7
0
 /// <summary>
 /// Returns the zero-based index of the given Edge, after sorting in ascending order
 /// by angle with the positive x-axis.
 /// </summary>
 /// <param name="edge"></param>
 /// <returns></returns>
 public int GetIndex(Edge edge)
 {
     return(deStar.GetIndex(edge));
 }
Beispiel #8
0
 /// <summary>
 /// Removes this directed edge from its containing graph.
 /// </summary>
 internal void Remove()
 {
     this.sym        = null;
     this.parentEdge = null;
 }