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

📄 ugraph.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
    copy_sym_ptrs[i] = const_cast<GraphVertex<TObject>* >      (arg_a.getCurr());    // move to the next node in the graph    //    const_cast<UGraph<TObject>& >(arg_a).gotoNext();  }  // before we assign the input graph we need to clear the current graph  //  this->clear(Integral::RESET);    // set the start and terminal vertices  //  this_sym_ptrs[0] = getStart();  this_sym_ptrs[num_vertices - 1] = getTerm();    for (long i = 1; i < num_vertices - 1; i++) {    // create a new graph vertex    //    this_sym_ptrs[i] = this->insertVertex(copy_sym_ptrs[i]->getItem());  }  // now build the arclists for each node  //  for (long i = 0; i < num_vertices; i++) {    // get the vertex in question    //    GraphVertex<TObject>* tmp_copy_vert = copy_sym_ptrs[i];    // loop over the copy graph's arclist    //    boolean arcs_remain = tmp_copy_vert->gotoFirst();    while (arcs_remain) {      // setup temporary variables      //      long dest_index = -1;      GraphArc<TObject>* tmp_arc = tmp_copy_vert->getCurr();      GraphVertex<TObject>* dest_vertex = tmp_arc->getVertex();      // find the destination vertex index      //      for (long j = 0; j < num_vertices; j++) {	if (dest_vertex == copy_sym_ptrs[j]) {	  dest_index = j;	  break;	}      }      if (dest_index == -1) {	return Error::handle(name(), L"assign", Error::ARG,			     __FILE__, __LINE__);      }      // link the vertices in the new graph      //      DiGraph<TObject>::insertArc(this_sym_ptrs[i], this_sym_ptrs[dest_index],				  tmp_arc->getEpsilon(), tmp_arc->getWeight());      // goto the next arc      //      arcs_remain = tmp_copy_vert->gotoNext();    }  }  // put the copy graph back in its original state  //  const_cast<UGraph<TObject>& >(arg_a).gotoPosition(old_pos);  // exit gracefully  //  return true;}//-------------------------------------------------------------------------////  required equality method////-------------------------------------------------------------------------// method: eq//// arguments://  const UGraph<TObject>& graph: (input) the graph to compare//// return: boolean value indicating test of equivalence//// this method compares two graph to see if they are equal. it can't// just call list-equality since all vertex pointers will be// different.//template<class TObject>boolean UGraph<TObject>::eq(const UGraph<TObject>& graph_a) const {  // create lists to extract the graph structures  //  SingleLinkedList<TObject> this_dlist;  SingleLinkedList<Triple<Pair<Long, Long>, Float, Boolean> > this_alist;  SingleLinkedList<TObject> input_dlist;  SingleLinkedList<Triple<Pair<Long, Long>, Float, Boolean> > input_alist;    // extract the structure of the current list  //  const_cast<UGraph<TObject>* >(this)->get(this_dlist, this_alist);    // extract the structure of the input list  //    const_cast<UGraph<TObject>& >(graph_a).get(input_dlist, input_alist);  // compare the lists for quality  //  if (!this_dlist.eq(input_dlist)) {    return false;  }  if (!this_alist.eq(input_alist)) {    return false;  }    // we have reached this far so the graphs have to be equal  //    return true;}//---------------------------------------------------------------------------//// class-specific public methods://  insert/remove arc methods////---------------------------------------------------------------------------// method: insertArc//// arguments://  GraphVertex<TObject>* start_vertex: (input) the start vertex//  GraphVertex<TObject>* end_vertex: (input) the ending vertex//  boolean is_epsilon: (input) is the arc an epsilon transition//  float weight: (input) the weight on the arc (if any)//  // return: a boolean value indicating status//// this method inserts arcs between two vertices in the graph provided// that the two vertices are already present in the graph//template<class TObject>boolean UGraph<TObject>::insertArc(GraphVertex<TObject>* start_vertex_a,				  GraphVertex<TObject>* end_vertex_a,				  boolean is_epsilon_a, float weight_a) {  // declare local variables  //  boolean return_val1 = false;  boolean return_val2 = false;    // make sure neither vertex is NULL  //  if ((start_vertex_a == (GraphVertex<TObject>*)NULL) ||      (end_vertex_a == (GraphVertex<TObject>*)NULL)) {    return Error::handle(name(), L"insertArc", Error::NULL_ARG,			 __FILE__, __LINE__);  }    // we don't allow connections between graphs so make sure the parent graph  // for both vertices is either already this graph or is null  //  if (((start_vertex_a->getParentGraph() != (UGraph<TObject>*)NULL) &&       (start_vertex_a->getParentGraph() != this)) ||      ((end_vertex_a->getParentGraph() != (UGraph<TObject>*)NULL) &&       (end_vertex_a->getParentGraph() != this))) {    return Error::handle(name(), L"insertArc", ERR_MULPAR, __FILE__,			 __LINE__);  }    // make sure that the start vertex and end vertex are already in the graph  //  if (!contains(start_vertex_a)) {    if ((start_vertex_a != start_vertex_d) &&	(start_vertex_a != term_vertex_d)) {      return Error::handle(name(), L"insertArc", Error::ARG,			   __FILE__, __LINE__);    }  }  if (!contains(end_vertex_a)) {    if ((end_vertex_a != start_vertex_d) &&	(end_vertex_a != term_vertex_d)) {      return Error::handle(name(), L"insertArc", Error::ARG,			   __FILE__, __LINE__);    }  }    // set the parent pointers regardless - this may be redundant but it is  // probably no less efficient than putting an if statement around it  //  start_vertex_a->setParentGraph(this);  end_vertex_a->setParentGraph(this);  // make sure that we do not duplicate self arcs  //  if (start_vertex_a == end_vertex_a) {    return_val2 = true;  }    // add an arc from the start to the end  //  return_val1 = start_vertex_a->insertArc(end_vertex_a, weight_a,					  is_epsilon_a);  // add an arc from the end to the start  //  if (start_vertex_a != end_vertex_a) {      return_val2 = end_vertex_a->insertArc(start_vertex_a, weight_a,						  is_epsilon_a);  }    // exit gracefully  //  return (return_val1 & return_val2);}// method: removeArc//// arguments://  GraphVertex<TObject>* start_vertex: (input) the start vertex//  GraphVertex<TObject>* end_vertex: (input) the ending vertex//  // return: a boolean value indicating status//// this method removes the arcs between two vertices from the graph structure// provided that the two vertices are already present in the graph//template<class TObject>boolean UGraph<TObject>::removeArc(GraphVertex<TObject>* start_vertex_a,				    GraphVertex<TObject>* end_vertex_a) {    // make sure neither vertex is NULL  //  if ((start_vertex_a == (GraphVertex<TObject>*)NULL) ||      (end_vertex_a == (GraphVertex<TObject>*)NULL)) {    return Error::handle(name(), L"removeArc", Error::NULL_ARG,			 __FILE__, __LINE__);  }  // make sure that both the start and end vertices are in the graph  //  if (!contains(end_vertex_a)) {    if (end_vertex_a != term_vertex_d) {      return Error::handle(name(), L"removeArc", ERR,			   __FILE__, __LINE__);    }  }  if (!contains(start_vertex_a)) {    if (start_vertex_a != start_vertex_d) {      return Error::handle(name(), L"removeArc", ERR,			   __FILE__, __LINE__);    }  }    // remove the arc form the start to the end vertex  //  boolean return_val1 = start_vertex_a->removeArc(end_vertex_a);  // remove the arc form the end to the start vertex  //  boolean return_val2 = end_vertex_a->removeArc(start_vertex_a);  // exit gracefully  //  return (return_val1 & return_val2);}// end of include file//#endif

⌨️ 快捷键说明

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