Ejemplo n.º 1
0
 /// <summary>
 /// Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges,
 /// to ensure the edges added are of the right class.
 /// </summary>
 /// <param name="dirEdge"></param>
 protected void Add(DirectedEdge dirEdge)
 {
     dirEdges.Add(dirEdge);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a DirectedEdge which is known to form part of this ring.
 /// </summary>
 /// <param name="de">The DirectedEdge to add.</param>
 public void Add(DirectedEdge de)
 {
     deList.Add(de);
 }
Ejemplo n.º 3
0
 /// <summary> 
 /// Removes DirectedEdge from its from-Node and from this PlanarGraph. Note:
 /// This method does not remove the Nodes associated with the DirectedEdge,
 /// even if the removal of the DirectedEdge reduces the degree of a Node to
 /// zero.
 /// </summary>
 /// <param name="de"></param>
 public void Remove(DirectedEdge de)
 {
     DirectedEdge sym = de.Sym;
     if (sym != null)
         sym.Sym = null;
     de.FromNode.OutEdges.Remove(de);
     de.Remove();
     dirEdges.Remove(de);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a new member to this DirectedEdgeStar.
 /// </summary>
 /// <param name="de"></param>
 public void Add(DirectedEdge de)
 {
     outEdges.Add(de);
     sorted = false;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="de"></param>
 /// <param name="pos"></param>
 /// <param name="list"></param>
 /// <param name="expectedClosed"></param>
 /// <returns></returns>
 private LinkedListNode<DirectedEdge> AddReverseSubpath(DirectedEdge de, LinkedListNode<DirectedEdge> pos,
     LinkedList<DirectedEdge> list,  bool expectedClosed)
 {
     // trace an unvisited path *backwards* from this de
     Node endNode = de.ToNode;
     Node fromNode = null;
     while (true)
     {
         if (pos == null)
              pos = list.AddLast(de.Sym);
         else pos = list.AddAfter(pos, de.Sym);
         de.Edge.Visited = true;
         fromNode = de.FromNode;
         DirectedEdge unvisitedOutDE = FindUnvisitedBestOrientedDE(fromNode);
         // this must terminate, since we are continually marking edges as visited
         if (unvisitedOutDE == null)
             break;
         de = unvisitedOutDE.Sym;
     }
     if (expectedClosed)
     {
         // the path should end at the toNode of this de, otherwise we have an error
         Assert.IsTrue(fromNode == endNode, "path not contiguous");
     }
     return pos;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns the DirectedEdge on the left-hand side of the given DirectedEdge (which
 /// must be a member of this DirectedEdgeStar). 
 /// </summary>
 /// <param name="dirEdge"></param>
 /// <returns></returns>
 public DirectedEdge GetNextEdge(DirectedEdge dirEdge)
 {
     int i = GetIndex(dirEdge);
     return (DirectedEdge)outEdges[GetIndex(i + 1)];
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Drops a member of this DirectedEdgeStar.
 /// </summary>
 /// <param name="de"></param>
 public void Remove(DirectedEdge de)
 {
     outEdges.Remove(de);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns the zero-based index of the given DirectedEdge, after sorting in ascending order
 /// by angle with the positive x-axis.
 /// </summary>
 /// <param name="dirEdge"></param>
 /// <returns></returns>
 public int GetIndex(DirectedEdge dirEdge)
 {
     SortEdges();
     for (int i = 0; i < outEdges.Count; i++)
     {
         DirectedEdge de = (DirectedEdge)outEdges[i];
         if (de == dirEdge)
             return i;
     }
     return -1;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds the Edge to this PlanarGraph; only subclasses can add DirectedEdges,
 /// to ensure the edges added are of the right class.
 /// </summary>
 /// <param name="dirEdge"></param>
 protected void Add(DirectedEdge dirEdge)
 {
     dirEdges.Add(dirEdge);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds an outgoing DirectedEdge to this Node.
 /// </summary>
 /// <param name="de"></param>
 public void AddOutEdge(DirectedEdge de)
 {
     deStar.Add(de);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructs an Edge initialized with the given DirectedEdges, and for each
 /// DirectedEdge: sets the Edge, sets the symmetric DirectedEdge, and adds
 /// this Edge to its from-Node.
 /// </summary>
 /// <param name="de0"></param>
 /// <param name="de1"></param>
 public Edge(DirectedEdge de0, DirectedEdge de1)
 {
     SetDirectedEdges(de0, de1);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes this Edge's two DirectedEdges, and for each DirectedEdge: sets the
 /// Edge, sets the symmetric DirectedEdge, and adds this Edge to its from-Node.
 /// </summary>
 /// <param name="de0"></param>
 /// <param name="de1"></param>
 public void SetDirectedEdges(DirectedEdge de0, DirectedEdge de1)
 {
     dirEdge = new DirectedEdge[] { de0, de1, };
     de0.Edge = this;
     de1.Edge = this;
     de0.Sym = de1;
     de1.Sym = de0;
     de0.FromNode.AddOutEdge(de0);
     de1.FromNode.AddOutEdge(de1);
 }