internal void addOwlEdge(IOwlEdge edge, int cnt, ref int numNull) { IOwlNode parent = edge.ParentNode; IOwlNode child = edge.ChildNode; NodeInstance childNode; NodeInstance parentNode; m_NodeDictionary.TryGetValue(child.ToString(), out childNode); m_NodeDictionary.TryGetValue(parent.ToString(), out parentNode); if (childNode == null || parentNode == null) { //if (childNode == null) //{ // //Debug.Log("no child node found for edge " + edge.ID); //} //if (parentNode == null) //{ // //Debug.Log("no parent node found for edge " + edge.ID); //} numNull++; return; } Vector3 childPos = childNode.m_treeNode.mPos; Vector3 parentPos = parentNode.m_treeNode.mPos; GameObject goEdge = DrawLine(childPos, parentPos, m_lineColor, m_OwlLineParent); /*EdgeInstance myEdge =*/ new EdgeInstance(/*edge,*/ childNode, parentNode, goEdge); }
/// <summary> /// Attaches a parent edge to this node. /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface.</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference.</exception> public void AttachParentEdge(IOwlEdge edge) { if (edge == null) { throw (new ArgumentNullException()); } bool exists = false; IOwlEdgeList edgeList = ParentEdges[edge.ID]; foreach (OwlEdge e in edgeList) { // First, we will look for an edge which is having the same parent and // child as the one we want to add if (e.ParentNode == edge.ParentNode) { exists = true; } } // If there is none, then we add the edge to this node if (!exists) { ParentEdges.Add(edge); edge.ChildNode = this; } // If not, then do nothing }
private IEnumerator DrawOwlEdges() { int numEdges = m_OwlGraph.Edges.Count; m_winText.text += "There are " + numEdges + " edges(s)."; IEnumerator edgeIter = m_OwlGraph.Edges.GetEnumerator(); int cnt = 0; int numNull = 0; while (edgeIter.MoveNext()) { IOwlEdge edge = (IOwlEdge)edgeIter.Current; m_EdgeManager.addOwlEdge(edge, cnt, ref numNull); if (cnt++ % m_addElementInterval == 0) { //Debug.Log("cnt = " + cnt); // can slow down drawing with call to WaitForSeconds // yield return new WaitForSeconds(m_edgeAddDelaySecs); yield return(null); } } yield return(null); }
/// <summary> /// Removes an edge object from the collection /// </summary> /// <param name="edge">The edge to remove</param> /// <returns>True if the edge was successfully removed</returns> /// <remarks>If the edge exists then it is removed by calling the ArrayList.Remove method which is an O(n) operation.</remarks> public virtual void Remove(IOwlEdge edge) { if (edge == null) { throw (new ArgumentNullException()); } _edges.Remove(edge); }
/// <summary> /// Determines whether an edge is present in this collection /// </summary> /// <param name="edge">The Edge to locate in the collection</param> /// <returns>True if the Edge was found in the collection</returns> /// <remarks>This method is a wrapper around the ArrayList.Contains(object) method and thus is O(<i>n</i>) operation. /// Additionally ArrayList.Contains calls Object.equals to determine equality and so you cannot use this method to determine if an edge with the same edgeID is a member of this collection.</remarks> public virtual bool Contains(IOwlEdge edge) { if (edge == null) { return(false); } return(_edges.Contains(edge)); }
/// <summary> /// Adds an OwlEdge to this collection /// </summary> /// <param name="newEdge">The Edge to add.</param> /// <exception cref="ArgumentNullException">newEdge is a null reference.</exception> public virtual void Add(IOwlEdge newEdge) { if (newEdge == null) { throw (new ArgumentNullException()); } _edges.Add(newEdge); }
/// <summary> /// Determines whether the specified edge object is present in this collection /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <returns>True if this collection contains the specified edge object</returns> /// <remarks>This method uses object.Equals to determine whether the specified edge object exists in the collection</remarks> public bool Contains(IOwlEdge edge) { if (!Contains(edge.ID)) { return(false); } return(((IOwlEdgeList)_edgeMap[edge.ID]).Contains(edge)); }
/// <summary> /// Attaches a child edge to this node. /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface. This is the new edge to attach.</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference.</exception> public void AttachChildEdge(IOwlEdge edge) { if (edge == null) { throw (new ArgumentNullException()); } ChildEdges.Add(edge); edge.ParentNode = this; }
/// <summary> /// Detaches a parent edge from this node. /// </summary> /// <param name="edge">An object that implements the IOwlNode interface.</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference.</exception> public void DetachParentEdge(IOwlEdge edge) { if (edge == null) { throw (new ArgumentNullException()); } if (ParentEdges.Contains(edge)) { ParentEdges.Remove(edge); edge.ChildNode = null; } }
/// <summary> /// Adds an edge to this collection /// </summary> /// <param name="edgeID">The ID of the edge</param> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference or the specified edgeID is a null reference</exception> public void Add(string edgeID, IOwlEdge edge) { IOwlEdgeList edgeList = (IOwlEdgeList)_edgeMap[edgeID]; if (edgeList == null) { edgeList = new OwlEdgeList(); _edgeMap[edgeID] = edgeList; } edgeList.Add(edge); _edges.Add(edge); }
/// <summary> /// Removes the specified edge object if it exists. /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <remarks>This method uses object.Equals to determine whether the specified edge exists and then removes it if it is present in the collection</remarks> public void Remove(IOwlEdge edge) { if (edge == null) { throw(new ArgumentNullException()); } IOwlEdgeList edgeList = (IOwlEdgeList)_edgeMap[edge.ID]; if (edgeList == null) { return; } edgeList.Remove(edge); _edges.Remove(edge); }
/// <summary> /// Detaches a parent edge from this node. /// </summary> /// <param name="edge">An object that implements the IOwlNode interface.</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference.</exception> public void DetachParentEdge(IOwlEdge edge) { if(edge == null) throw (new ArgumentNullException()); if(ParentEdges.Contains(edge)) { ParentEdges.Remove(edge); edge.ChildNode = null; } }
/// <summary> /// Attaches a child edge to this node. /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface. This is the new edge to attach.</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference.</exception> public void AttachChildEdge(IOwlEdge edge) { if(edge == null) throw (new ArgumentNullException()); ChildEdges.Add(edge); edge.ParentNode = this; }
/// <summary> /// Determines whether an edge is present in this collection /// </summary> /// <param name="edge">The Edge to locate in the collection</param> /// <returns>True if the Edge was found in the collection</returns> /// <remarks>This method is a wrapper around the ArrayList.Contains(object) method and thus is O(<i>n</i>) operation. /// Additionally ArrayList.Contains calls Object.equals to determine equality and so you cannot use this method to determine if an edge with the same edgeID is a member of this collection.</remarks> public virtual bool Contains(IOwlEdge edge) { if(edge == null) return false; return _edges.Contains(edge); }
/// <summary> /// Adds an edge to the graph /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <exception cref="ArgumentNullException">The specified edge object is a null reference</exception> public void AddEdge(IOwlEdge edge) { _edges.Add((OwlEdge)edge); }
/// <summary> /// Adds an edge to this collection /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference</exception> public void Add(IOwlEdge edge) { Add(edge.ID, edge); }
/// <summary> /// Adds an OwlEdge to this collection /// </summary> /// <param name="newEdge">The Edge to add.</param> /// <exception cref="ArgumentNullException">newEdge is a null reference.</exception> public virtual void Add(IOwlEdge newEdge) { if(newEdge == null) throw (new ArgumentNullException()); _edges.Add(newEdge); }
/// <summary> /// Adds an edge to this collection /// </summary> /// <param name="edgeID">The ID of the edge</param> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference or the specified edgeID is a null reference</exception> public void Add(string edgeID, IOwlEdge edge) { IOwlEdgeList edgeList = (IOwlEdgeList)_edgeMap[edgeID]; if(edgeList == null) { edgeList = new OwlEdgeList(); _edgeMap[edgeID] = edgeList; } edgeList.Add(edge); _edges.Add(edge); }
/// <summary> /// Removes an edge object from the collection /// </summary> /// <param name="edge">The edge to remove</param> /// <returns>True if the edge was successfully removed</returns> /// <remarks>If the edge exists then it is removed by calling the ArrayList.Remove method which is an O(n) operation.</remarks> public virtual void Remove(IOwlEdge edge) { if(edge == null) throw (new ArgumentNullException()); _edges.Remove(edge); }
/// <summary> /// Determines whether the specified edge object is present in this collection /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <returns>True if this collection contains the specified edge object</returns> /// <remarks>This method uses object.Equals to determine whether the specified edge object exists in the collection</remarks> public bool Contains(IOwlEdge edge) { if(!Contains(edge.ID)) return false; return ((IOwlEdgeList)_edgeMap[edge.ID]).Contains(edge); }
/// <summary> /// Attaches a parent edge to this node. /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface.</param> /// <exception cref="ArgumentNullException">The specified edge is a null reference.</exception> public void AttachParentEdge(IOwlEdge edge) { if(edge == null) throw (new ArgumentNullException()); bool exists = false; IOwlEdgeList edgeList = ParentEdges[edge.ID]; foreach(OwlEdge e in edgeList) { // First, we will look for an edge which is having the same parent and // child as the one we want to add if(e.ParentNode == edge.ParentNode) { exists = true; } } // If there is none, then we add the edge to this node if(! exists) { ParentEdges.Add(edge); edge.ChildNode = this; } // If not, then do nothing }
/// <summary> /// Removes the specified edge object if it exists. /// </summary> /// <param name="edge">An object that implements the IOwlEdge interface</param> /// <remarks>This method uses object.Equals to determine whether the specified edge exists and then removes it if it is present in the collection</remarks> public void Remove(IOwlEdge edge) { if(edge == null) throw(new ArgumentNullException()); IOwlEdgeList edgeList = (IOwlEdgeList)_edgeMap[edge.ID]; if(edgeList == null) return; edgeList.Remove(edge); _edges.Remove(edge); }