Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public virtual Node AddNode(Node n)
 {
     Node node = (Node)nodeMap[n.Coordinate];
     if (node == null) 
     {
         nodeMap.Add(n.Coordinate, n);
         return n;
     }
     node.MergeLabel(n);
     return node;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Label an isolated node with its relationship to the target point.
 /// </summary>
 private void LabelIncompleteNode(Node n, int targetIndex)
 {
     Locations loc = ptLocator.Locate(n.Coordinate, arg[targetIndex].Geometry);
     n.Label.SetLocation(targetIndex, loc);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates the subgraph consisting of all edges reachable from this node.
 /// Finds the edges in the graph and the rightmost coordinate.
 /// </summary>
 /// <param name="node">A node to start the graph traversal from.</param>
 public virtual void Create(Node node)
 {
     AddReachable(node);
     finder.FindEdge(dirEdgeList);
     rightMostCoord = finder.Coordinate;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="n"></param>
        private void ComputeNodeDepth(Node n)
        {
            // find a visited dirEdge to start at
            DirectedEdge startEdge = null;
            IEnumerator i = ((DirectedEdgeStar)n.Edges).GetEnumerator();
            while (i.MoveNext()) 
            {
                DirectedEdge de = (DirectedEdge) i.Current;
                if (de.IsVisited || de.Sym.IsVisited)
                {
                    startEdge = de;
                    break;
                }
            }

            // MD - testing  Result: breaks algorithm
            Assert.IsTrue(startEdge != null, "unable to find edge to compute depths at " + n.Coordinate);
            ((DirectedEdgeStar) n.Edges).ComputeDepths(startEdge);

            // copy depths to sym edges
            IEnumerator j = ((DirectedEdgeStar) n.Edges).GetEnumerator();
            while (j.MoveNext())
            {
                DirectedEdge de = (DirectedEdge) j.Current;
                de.IsVisited = true;
                CopySymDepths(de);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the argument node and all its out edges to the subgraph
 /// </summary>
 /// <param name="node">The node to add.</param>
 /// <param name="nodeStack">The current set of nodes being traversed.</param>
 private void Add(Node node, Stack nodeStack)
 {
     node.IsVisited = true;
     nodes.Add(node);
     for (IEnumerator i = ((DirectedEdgeStar) node.Edges).GetEnumerator(); i.MoveNext(); ) 
     {
         DirectedEdge de = (DirectedEdge) i.Current;
         dirEdgeList.Add(de);
         DirectedEdge sym = de.Sym;
         Node symNode = sym.Node;
         /*
         * NOTE: this is a depth-first traversal of the graph.
         * This will cause a large depth of recursion.
         * It might be better to do a breadth-first traversal.
         */
         if (! symNode.IsVisited) 
             nodeStack.Push(symNode);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds all nodes and edges reachable from this node to the subgraph.
 /// Uses an explicit stack to avoid a large depth of recursion.
 /// </summary>
 /// <param name="startNode">A node known to be in the subgraph.</param>
 private void AddReachable(Node startNode)
 {
     Stack nodeStack = new Stack();
     nodeStack.Push(startNode);
     while (nodeStack.Count != 0) 
     {
         Node node = (Node) nodeStack.Pop();
         Add(node, nodeStack);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Label an isolated node with its relationship to the target point.
 /// </summary>
 /// <param name="n"></param>
 /// <param name="targetIndex"></param>
 private void LabelIsolatedNode(Node n, int targetIndex)
 {
     Locations loc = ptLocator.Locate(n.Coordinate, arg[targetIndex].Geometry);
     n.Label.SetAllLocations(targetIndex, loc);        
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds the specified node to the geometry graph's NodeMap
 /// </summary>
 /// <param name="node">The node to add</param>
 /// <returns>The node after the addition</returns>
 public virtual Node AddNode(Node node)
 {
     return _nodes.AddNode(node);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="n"></param>
 public virtual void MergeLabel(Node n)
 {
     MergeLabel(n.Label);
 }