예제 #1
0
파일: NodeMap.cs 프로젝트: izambakci/tf-net
 /// <summary>
 /// 
 /// </summary>
 /// <param name="n"></param>
 /// <returns></returns>
 public 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;
 }
예제 #2
0
파일: Node.cs 프로젝트: izambakci/tf-net
 /// <summary>
 /// 
 /// </summary>
 /// <param name="n"></param>
 public void MergeLabel(Node n)
 {
     MergeLabel(n.Label);
 }
예제 #3
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.Visited = true;
                CopySymDepths(de);
            }
        }
예제 #4
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);
     }
 }
예제 #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.Visited = 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);
     }
 }
예제 #6
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 void Create(Node node)
 {
     AddReachable(node);
     finder.FindEdge(dirEdgeList);
     rightMostCoord = finder.Coordinate;
 }
예제 #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);
 }
예제 #8
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);
 }
예제 #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public Node AddNode(Node node)
 {
     return nodes.AddNode(node);
 }