#ifdef __cplusplus extern "C" { #endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #undef do_open #undef do_close #undef apply #undef ref #ifdef __cplusplus } #endif //____________________________________________________________________________________________________ // C++ #undef list #include #include #include #include #include #include #include "BoostGraph_i.h" #include using namespace std; using namespace boost; typedef property Weight; typedef adjacency_list DirectedGraph; typedef std::pair, double> Path; class BoostGraph { public: BoostGraph_i* BGi; BoostGraph() { this->BGi = new BoostGraph_i; } ~BoostGraph() { // delete BGi; } bool _addNode(int nodeId) { bool ret = BGi->addNode(nodeId); // cout << "_addNode(" << nodeId << ")\n"; return ret; } bool _addEdge(int nodeIdSource, int nodeIdSink, double weightVal) { bool ret = BGi->addEdge(nodeIdSource, nodeIdSink, weightVal); // cout << "_addEdge(" << nodeIdSource <<","<< nodeIdSink <<","<< weightVal << ")\n"; return ret; } double allPairsShortestPathsJohnson(int nodeIdStart, int nodeIdEnd) { double ret = BGi->allPairsShortestPathsJohnson(nodeIdStart,nodeIdEnd); return ret; } }; //____________________________________________________________________________________________________ // C-Perl tying MODULE = Boost::Graph::Directed PACKAGE = Boost::Graph::Directed BoostGraph * BoostGraph::new() void BoostGraph::DESTROY() bool BoostGraph::_addNode(int nodeId) bool BoostGraph::_addEdge(int nodeIdSource, int nodeIdSink, double weightVal) void BoostGraph::breadthFirstSearch(int startNodeId) PPCODE: std::vector bfs = THIS->BGi->breadthFirstSearch(startNodeId); for(unsigned int i=0; i dfs = THIS->BGi->depthFirstSearch(startNodeId); for(unsigned int i=0; iBGi->dijkstraShortestPath(nodeIdStart, nodeIdEnd); XPUSHs(sv_2mortal(newSVnv(pInfo.second))); // the path weight for(unsigned int i=0; i