⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bigraphvertex.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 4 页
字号:
  //  if (vertex_found) {    // if the found vertex was at the current node position then remove the    // node    //    if (this->getMarkParent() == tmp_item) {      // remove the arc from the graph      //      boolean status = false;      BiGraphArc<TObject>* graph_arc;      status = removeParent(graph_arc);      delete graph_arc;      if (!status) {	return false;      }    }    else {      // remove the node      //      boolean status = false;      BiGraphArc<TObject>* graph_arc;      status = removeParent(graph_arc);      delete graph_arc;            if (!status) {	return false;      }    }  }  else {    return false;  }  // restore the saved state  //  this->gotoMarkParent();    // exit gracefully  //  return true;}// method: removeArcChild//// arguments: none//// return: a boolean value indicating status//// this method unlinks this vertex from the vertex linked by the current arc// in the list. if the BiGraph is not directed, then an arc from the found// vertex is removed as well//template<class TObject>boolean BiGraphVertex<TObject>::removeArcChild() {  // if the adjacency list is empty then return false  //  if (isEmptyChild()) {    return false;  }  // remove this arc  //  boolean status = false;  BiGraphArc<TObject>* bigraph_arc;    status = removeChild(bigraph_arc);  delete bigraph_arc;    // exit gracefully  //  return status;}// method: removeArcParent//// arguments: none//// return: a boolean value indicating status//// this method unlinks this vertex from the vertex linked by the current arc// in the list. if the BiGraph is not directed, then an arc from the found// vertex is removed as well//template<class TObject>boolean BiGraphVertex<TObject>::removeArcParent() {  // if the adjacency list is empty then return false  //  if (isEmptyParent()) {    return false;  }  // remove this arc  //  boolean status = false;  BiGraphArc<TObject>* bigraph_arc;    status = removeParent(bigraph_arc);  delete bigraph_arc;    // exit gracefully  //  return status;}// method: removeAllArcsChild//// arguments: none//// return: a boolean value indicating status//// this method removes all arcs extending from this vertex//template<class TObject>boolean BiGraphVertex<TObject>::removeAllArcsChild() {  // declare a return value  //  boolean return_val = true;  // loop until no arcs remain  //  while (!isEmptyChild()) {        // remove the forward link    //    boolean status = false;    BiGraphArc<TObject>* bigraph_arc;    status = removeChild(bigraph_arc);    delete bigraph_arc;        // exit gracefully    //    return_val &= status;      }  // exit gracefully  //  return return_val;}// method: removeAllArcsParent//// arguments: none//// return: a boolean value indicating status//// this method removes all arcs extending from this vertex//template<class TObject>boolean BiGraphVertex<TObject>::removeAllArcsParent() {  // declare a return value  //  boolean return_val = true;  // loop until no arcs remain  //  while (!isEmptyParent()) {        // remove the forward link    //    boolean status = false;    BiGraphArc<TObject>* bigraph_arc;    status = removeParent(bigraph_arc);    delete bigraph_arc;        // exit gracefully    //    return_val &= status;      }    // exit gracefully  //  return return_val;}// method: isAdjacentChild//// arguments://  BiGraphVertex<TObject>* vertex: (input) the vertex to find//// return: boolean flag indicating whether or not the vertex was found//// this method finds the input vertex in the adjacency list for this// vertex//template<class TObject>boolean BiGraphVertex<TObject>::isAdjacentChild(BiGraphVertex<TObject>*						vertex_a) const {  // make sure the list is not empty  //  if (isEmptyChild()) {    return false;  }  // save the current state  //  this->setMarkChild();    // find the input vertex in the adjacency list by looping over all arcs  //  BiGraphArc<TObject>* tmp_item = (BiGraphArc<TObject> *)NULL;  if (const_cast<BiGraphVertex<TObject>* >(this)->gotoFirstChild()) {    tmp_item = this->getCurrChild();  }  // declare temporary objects  //  BiGraphVertex<TObject>* tmp_vert = (BiGraphVertex<TObject>*) NULL;  // loop over each element and look for the input vertex  //  boolean vertex_found = false;  while ((tmp_item != (BiGraphArc<TObject> *)NULL) &&	 !vertex_found) {    // get the vertex out of the node    //    tmp_vert = tmp_item->getVertex();    // check to see if the found vertex is the one we are looking for    //    if (tmp_vert == vertex_a) {      vertex_found = true;    }    else {      if (const_cast<BiGraphVertex<TObject>* >(this)->gotoNextChild()) {	tmp_item = this->getCurrChild();      }      else {	tmp_item = (BiGraphArc<TObject> *)NULL;      }    }  }  // restore the saved state  //  const_cast<BiGraphVertex<TObject>* >(this)->gotoMarkChild();    // exit gracefully  //  return vertex_found;}// method: isAdjacentParent//// arguments://  BiGraphVertex<TObject>* vertex: (input) the vertex to find//// return: boolean flag indicating whether or not the vertex was found//// this method finds the input vertex in the adjacency list for this// vertex//template<class TObject>boolean BiGraphVertex<TObject>::isAdjacentParent(BiGraphVertex<TObject>*						vertex_a) const {  // make sure the list is not empty  //  if (isEmptyParent()) {    return false;  }  // save the current state  //  this->setMarkParent();    // find the input vertex in the adjacency list by looping over all arcs  //  BiGraphArc<TObject>* tmp_item = (BiGraphArc<TObject> *)NULL;  if (const_cast<BiGraphVertex<TObject>* >(this)->gotoFirstParent()) {    tmp_item = this->getCurrParent();  }  // declare temporary objects  //  BiGraphVertex<TObject>* tmp_vert = (BiGraphVertex<TObject>*) NULL;  // loop over each element and look for the input vertex  //  boolean vertex_found = false;  while ((tmp_item != (BiGraphArc<TObject> *)NULL) &&	 !vertex_found) {    // get the vertex out of the node    //    tmp_vert = tmp_item->getVertex();    // check to see if the found vertex is the one we are looking for    //    if (tmp_vert == vertex_a) {      vertex_found = true;    }    else {      if (const_cast<BiGraphVertex<TObject>* >(this)->gotoNextParent()) {	tmp_item = this->getCurrParent();      }      else {	tmp_item = (BiGraphArc<TObject> *)NULL;      }    }  }  // restore the saved state  //  const_cast<BiGraphVertex<TObject>* >(this)->gotoMarkParent();    // exit gracefully  //  return vertex_found;}//---------------------------------------------------------------------------//// class-specific public methods://  vertex comparison methods////---------------------------------------------------------------------------// method: compareVertices//// arguments://  const BiGraphVertex<TObject>& compare_vertex: (input) the vertex to compare//// return: boolean value indicating test of equivalence//// this method compares two vertices for equivalent structure//template<class TObject>boolean BiGraphVertex<TObject>::compareVertices(const BiGraphVertex<TObject>&						vertex_a) const {  // declare the output variable  //  boolean arc_equal = false;    // check for null items in either vertex  //  if (item_d == (TObject*)NULL) {    if (vertex_a.item_d != (TObject*)NULL) {      return false;    }  }  else if (vertex_a.item_d == (TObject*)NULL) {    return false;  }  // make sure that the vertices have the same number of arcs  //  if (this->lengthChild() != vertex_a.lengthChild()) {      // if the lengths are different then the number of arcs in the      // vertex are different      //      return false;      }    // save the current states  //  this->setMarkChild();  vertex_a.setMarkChild();    // iterate over all arcs contained in the current vertex  //  boolean more_nodes = const_cast< BiGraphVertex<TObject>* >(this)->gotoFirstChild();      while (more_nodes) {    // get the current arc associated with the vertex    //    arc_equal = false;    BiGraphArc<TObject>* this_arc = const_cast< BiGraphVertex<TObject>* >      (this)->getCurrChild();    // iterate over all  arcs associated with the input vertex    //    boolean more_nodes1 =      const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoFirstChild();    while (more_nodes1) {      // get the current arc associated with the vertex      //      BiGraphArc<TObject>* input_arc = const_cast< BiGraphVertex<TObject>& >	(vertex_a).getCurrChild();      // check if the arcs are similar      //      if (this_arc->eq(*input_arc)) {	arc_equal = true;      }      // get the next arc in the vertex      //      more_nodes1 = const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoNextChild();    }    // if none of the arcs in the input vector are similar exit    //    if (!arc_equal) {      const_cast< BiGraphVertex<TObject>* >(this)->gotoMarkChild();      const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoMarkChild();          return false;    }        // get the next arc in the vertex    //    more_nodes = const_cast< BiGraphVertex<TObject>* >(this)->gotoNextChild();  }    // reset the current pointer and return true  //  const_cast< BiGraphVertex<TObject>* >(this)->gotoMarkChild();  const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoMarkChild();  // make sure that the vertices have the same number of arcs  //  if (this->lengthParent() != vertex_a.lengthParent()) {      // if the lengths are different then the number of arcs in the      // vertex are different      //      return false;      }    // save the current states  //  this->setMarkParent();  vertex_a.setMarkParent();    // iterate over all arcs contained in the current vertex  //  more_nodes = const_cast< BiGraphVertex<TObject>* >(this)->gotoFirstParent();      while (more_nodes) {    // get the current arc associated with the vertex    //    arc_equal = false;    BiGraphArc<TObject>* this_arc = const_cast< BiGraphVertex<TObject>* >      (this)->getCurrParent();    // iterate over all  arcs associated with the input vertex    //    boolean more_nodes1 =      const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoFirstParent();    while (more_nodes1) {      // get the current arc associated with the vertex      //      BiGraphArc<TObject>* input_arc = const_cast< BiGraphVertex<TObject>& >	(vertex_a).getCurrParent();      // check if the arcs are similar      //      if (this_arc->eq(*input_arc)) {	arc_equal = true;      }      // get the next arc in the vertex      //      more_nodes1 = const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoNextParent();    }    // if none of the arcs in the input vector are similar exit    //    if (!arc_equal) {      const_cast< BiGraphVertex<TObject>* >(this)->gotoMarkParent();      const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoMarkParent();          return false;    }        // get the next arc in the vertex    //    more_nodes = const_cast< BiGraphVertex<TObject>* >(this)->gotoNextParent();  }    // reset the current pointer and return true  //  const_cast< BiGraphVertex<TObject>* >(this)->gotoMarkParent();  const_cast< BiGraphVertex<TObject>& >(vertex_a).gotoMarkParent();  // exit gracefully  //  return true;}// end of include file//#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -