shape_doc 0.1
|
#include <graph.hpp>
GraphDfsIter< T > * createIterator | ( | ) | const |
Definition at line 305 of file graph.hpp.
{ return new GraphDfsIter<T>(this); }
void delete_edge | ( | T | v_val, |
T | e_val | ||
) |
void delete_vertex | ( | T | val | ) |
Deletes a vertex and all incident edges.
Definition at line 501 of file graph.hpp.
References head.
{ if(head==NULL) return; nvertices--; gNode<T>* e=head; // Delete edges from other vertices lists while(e!=NULL) { delete_edge(e->data,v_val); e=e->vlist; } // Delete incident edges e=head; while(e!=NULL) { delete_edge(v_val,e->data); e=e->vlist; } //Delete Vertex if(head->data==v_val) { gNode<T>* temp=head; head=head->vlist; delete temp; return; } gNode<T>* p1=head->vlist; gNode<T>* p2=head; while(p1!=NULL) { if(p1->data==v_val) { p2->vlist=p1->vlist; p1=NULL; delete p1; return; } p2=p1; p1=p1->vlist; } }
void dfs | ( | Seq< T > & | out | ) |
void dfs | ( | func | fp | ) |
DFS traversal (run operation fp on nodes)
Definition at line 602 of file graph.hpp.
References head, and gNode< T >::status().
Referenced by mmx::shape::print_boxes().
gNode< T > * dfs | ( | test_node | fp | ) |
DFS search (find a node that satisfies test fp)
Definition at line 705 of file graph.hpp.
References head, NODESTACK, and gNode< T >::status().
{ gNode<T>* t=head; while(t!=NULL) { t->status(-1); t=t->vlist; } t=head; while(t!=NULL) { if (t->status()==-1) { NODESTACK q; gNode<T> * s; q.push(t); t->status(0); // mark as visited while ( !q.empty() ) { s=q.top(); q.pop(); if (fp!=NULL) if ( (*fp)(s) ) // check node return s; while(t->next!=NULL) { if (t->next->status()==-1) { t->status(0); // mark as visited q.push(t->next->start); } t=t->next; } } } t=t->vlist; } return NULL; }
void dfs_walk | ( | gNode< T > * | s, |
Seq< T > & | out | ||
) |
Definition at line 673 of file graph.hpp.
References NODESTACK, and gNode< T >::status().
{ NODESTACK q; gNode<T> * t; q.push(s); while ( !q.empty() ) { t=q.top(); q.pop(); if ( t->status()==-1) { out<< t->data; // output node data t->status(0); // mark as visited } while(t->next!=NULL) { if ( t->next->status() == -1 ) { q.push(t->next->start); } t=t->next; } } }
void dfs_walk | ( | gNode< T > * | s, |
func | fp | ||
) |
Definition at line 621 of file graph.hpp.
References NODESTACK, and gNode< T >::status().
{ NODESTACK q; gNode<T> * t; q.push(s); s->status(0); // mark as visited while ( !q.empty() ) { t=q.top(); q.pop(); if (fp!=NULL) (*fp)(t); // run operation on node //std::cout<< t->data<<std::endl; while(t->next!=NULL) { if (t->next->status()==-1) { t->status(0); // mark as visited q.push(t->next->start); } t=t->next; } } }
void edge_list | ( | Seq< T > & | e | ) | const |
gNode< T > * get_start_node | ( | ) |
bool member | ( | T | val | ) | const [inline] |
Seq< T > neighbors | ( | T | e | ) |
T next | ( | T | val | ) | const [inline] |
void print | ( | ) | [inline] |
Print rep of graph - for testing.
Definition at line 171 of file graph.hpp.
{ std::cout<< "Graph: "<< std::endl; gNode<T> *s, *t=head; while(t!=NULL) { std::cout<< t->data<<" ===> "; s=t->next; while(s!=NULL) { std::cout<< s->data<<", "; s=s->next;} std::cout<< std::endl; t=t->vlist; } std::cout<< std::endl; }
void push_edge | ( | T | v_val, |
T | e_val | ||
) |
Insert edge.
Definition at line 337 of file graph.hpp.
References head.
Referenced by Graph< Point * >::push_uedge().
{ if(head==NULL) return; nedges++; gNode<T>* t=head; while(t!=NULL) //find vertex v { if(t->data==v_val) { gNode<T>* temp=new gNode<T>(e_val); while(t->next!=NULL) t=t->next; t->next=temp;// add e to v's neighbors t=head;//update node info while(t!=NULL) { if(t->data==e_val) { temp->me=t->me; t->me=temp; //temp->vlist=t->vlist; temp->start=t; } t=t->vlist; } return; } t=t->vlist; } }
void push_uedge | ( | T | v_val, |
T | e_val | ||
) | [inline] |
Definition at line 138 of file graph.hpp.
Referenced by voronoi2d< C, V >::insert_regular().
gNode< T > * push_vertex | ( | T | val, |
int | i = 0 |
||
) |
Insert vertex.
Definition at line 312 of file graph.hpp.
References gNode< T >::aux(), and head.
Referenced by voronoi2d< C, V >::insert_regular().
bool set_start_node | ( | T & | val | ) |
bool set_start_node | ( | T & | v_val, |
T & | e_val | ||
) |
Definition at line 577 of file graph.hpp.
References head.
{ gNode<T>* k=this->head->next; if (!set_start_node(v_val)) return false; while(k->next!=NULL) { if(k->next->data==e_val) break; k=k->next; } if (k->next==NULL) return false; gNode<T> *u= k->next; k->next = u->next; u->next = this->head->next; this->head->next= u; }
void vertex_list | ( | Seq< T > & | v | ) | const |
friend class GraphDfsIter< T > [friend] |