Graph.cpp

Go to the documentation of this file.
00001 
00022 #include "Graph.hpp"
00023 
00024 namespace OA {
00025 
00026 //--------------------------------------------------------------------
00030 OA_ptr<BaseGraph::Node>
00031 Graph::create_DFS_links (OA_ptr<BaseGraph::Node> n)
00032 {/* AIS - commented out in order to get OA to compile
00033   OA_ptr<NodesIterator> neigh =
00034     (n.convert<Node>())->getNeighborNodesIterator();;
00035   OA_ptr<BaseGraph::Node> last = n;
00036   while (neigh->isValid()) {
00037     if (neigh->current()->dfs_succ.ptrEqual(0)) {
00038       OA_ptr<Node> n = neigh->current(); // Stupid Sun CC 5.4
00039       // cast is needed to access protected member
00040       (last.convert<Node>())->dfs_succ = n.convert<BaseGraph::Node>();
00041       last = create_DFS_links(neigh->current());
00042     }
00043     ++(*neigh);
00044   }
00045   // cast is needed to access protected member
00046   (last.convert<Node>())->dfs_succ = 0;
00047   return last;*/
00048 }
00049 //--------------------------------------------------------------------
00050 
00051 
00052 //--------------------------------------------------------------------
00056 OA_ptr<BaseGraph::Node>
00057 Graph::create_BFS_links (OA_ptr<BaseGraph::Node> n)
00058 {
00059   return n;
00060 }
00061 //--------------------------------------------------------------------
00062 
00063 
00064 //--------------------------------------------------------------------
00066 void
00067 Graph::addNode (OA_ptr<Graph::Node> n)
00068 {
00069   BaseGraph::addNode(n);
00070 }
00071 //--------------------------------------------------------------------
00072 
00073 
00074 //--------------------------------------------------------------------
00078 void
00079 Graph::addEdge (OA_ptr<Graph::Edge> e)
00080 {
00081   BaseGraph::addEdge(e);
00082   e->node1()->incident_edges->push_back(e);
00083   e->node2()->incident_edges->push_back(e);
00084 }
00085 //--------------------------------------------------------------------
00086 
00087 
00088 //--------------------------------------------------------------------
00092 void
00093 Graph::removeEdge (OA_ptr<Graph::Edge> e)
00094 {
00095   BaseGraph::removeEdge(e);
00096 
00097   // remove this edge from the list of incident edges of the two nodes involved
00098   e->node1()->incident_edges->remove(e);
00099   e->node2()->incident_edges->remove(e);
00100 }
00101 //--------------------------------------------------------------------
00102 
00103 
00104 //--------------------------------------------------------------------
00106 void
00107 Graph::removeNode (OA_ptr<Graph::Node> n)
00108 {
00109 /* AIS - temporarily commented out so I can get OA to compile.
00110   BaseGraph::removeNode(n);
00111 
00112   // remove all the edges incident on this node
00113   OA_ptr<EdgesIterator> incident = n->getIncidentEdgesIterator();
00114   while (incident->isValid()) {
00115     OA_ptr<Edge> e = incident->current();
00116     // remove this edge from the neighboring node's list of incident edges
00117     if (e->node1().ptrEqual(n)) {
00118       e->node2()->incident_edges->remove(e);
00119     } else {
00120       e->node1()->incident_edges->remove(e);
00121     }
00122     // remove this edge
00123     BaseGraph::removeEdge(e);
00124     ++incident;
00125   }*/
00126 }
00127 //--------------------------------------------------------------------
00128 
00129 } // end of OA namespace