/// <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; }
/// <summary> /// /// </summary> /// <param name="n"></param> public virtual void MergeLabel(Node n) { MergeLabel(n.Label); }
/// <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); }
/// <summary> /// /// </summary> /// <param name="n"></param> private static void ComputeNodeDepth(Node n) { // find a visited dirEdge to start at DirectedEdge startEdge = null; IEnumerator i = 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 = n.Edges.GetEnumerator(); while (j.MoveNext()) { DirectedEdge de = (DirectedEdge)j.Current; de.IsVisited = true; CopySymDepths(de); } }
/// <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 = node.Edges.GetEnumerator(); i.MoveNext(); ) { DirectedEdge de = (DirectedEdge)i.Current; _dirEdgeList.Add(de); DirectedEdge sym = de.Sym; Node symNode = sym.Node; /* * Notice: 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); } }
/// <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); } }
/// <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; }
/// <summary> /// Label an isolated node with its relationship to the target point. /// </summary> private void LabelIncompleteNode(Node n, int targetIndex) { LocationType loc = _ptLocator.Locate(n.Coordinate, Arg[targetIndex].Geometry); n.Label.SetLocation(targetIndex, loc); }