@@ -71,7 +71,7 @@ std::vector<std::vector<T>> readLines(std::string inputFileName, char delim) {
7171
7272 inputFile.open (inputFileName);
7373 if (!inputFile){
74- throw std::system_error (errno, std::system_category (), " failed to open " +inputFileName);
74+ throw std::system_error (errno, std::system_category (), " failed to open file with interval solution " +inputFileName);
7575 }
7676
7777 std::string line;
@@ -167,6 +167,7 @@ public:
167167 template <class PAR > VertexGroups (PAR& parameters){
168168 // std::vector<std::vector<size_t>> groups;
169169
170+ std::cout<<" time file name check 2 " <<parameters.getTimeFileName ()<<std::endl;
170171 initFromFile (parameters.getTimeFileName (),parameters);
171172// std::string line;
172173// std::vector<std::string> strings;
@@ -309,11 +310,12 @@ inline void VertexGroups<T>::initFromFile(const std::string& fileName, const PAR
309310 size_t maxTimeToRead=parameters.getMaxTimeFrame ();
310311
311312
313+ std::cout<<" time file name check 3 " <<fileName<<std::endl;
312314 std::ifstream timeData;
313315 try {
314316 timeData.open (fileName);
315317 if (!timeData){
316- throw std::system_error (errno, std::system_category (), " failed to open " +fileName);
318+ throw std::system_error (errno, std::system_category (), " failed to open file with vertices in time layers " +fileName);
317319 }
318320
319321 unsigned int previousTime=1 ;
@@ -689,6 +691,7 @@ public:
689691 template <class PAR >
690692 CompleteStructure (PAR & configParameters)
691693{
694+ std::cout<<" time file name check 1 " <<configParameters.getTimeFileName ()<<std::endl;
692695 pVertexGroups=new VertexGroups<>(configParameters);
693696 VertexGroups<>& vg=*pVertexGroups;
694697 maxTime=vg.getMaxTime ();
@@ -725,6 +728,8 @@ public:
725728 template <class PAR >
726729 void addEdgesFromFile (const std::string& fileName,PAR& params);
727730 void addEdgesFromMatrix (size_t time1,size_t time2,const py::array_t <double > inputMatrix);
731+ template <class PAR >
732+ void addEdgesFromVectors (const py::array_t <size_t >edges,const py::array_t <double > costs,PAR& params);
728733 const VertexGroups<>& getVertexGroups (){
729734 return *pVertexGroups;
730735 }
@@ -742,6 +747,49 @@ private:
742747
743748};
744749
750+ template <class T >
751+ template <class PAR >
752+ inline void CompleteStructure<T>::addEdgesFromVectors(const py::array_t <size_t > edges,const py::array_t <double > costs,PAR& params){
753+ char delim=' ,' ;
754+ VertexGroups<>& vg=*pVertexGroups;
755+
756+ const auto edgeVector=edges.unchecked <2 >();
757+ const std::size_t dim1=edgeVector.shape (0 );
758+ const std::size_t dim2=edgeVector.shape (1 );
759+ const auto costVector=costs.unchecked <1 >();
760+ const size_t dimOfCosts=costVector.shape (0 );
761+
762+
763+ if (dim2!=2 ){
764+ std::string message=" Wrong dimension of edge array, second dimension 2 expected" ;
765+ throw std::invalid_argument (message);
766+ }
767+ if (dim1!=dimOfCosts){
768+ std::string message=" Dimension of edge array and edge costs do not match." ;
769+ throw std::invalid_argument (message);
770+ }
771+
772+ params.getControlOutput ()<<" Reading base edges from vector. " <<std::endl;
773+ params.writeControlOutput ();
774+ for (size_t i=0 ;i<dim1;i++) {
775+ size_t v=edgeVector (i,0 );
776+ size_t w=edgeVector (i,1 );
777+ double edgeCost=costVector (i);
778+
779+ size_t l0=vg.getGroupIndex (v);
780+ size_t l1=vg.getGroupIndex (w);
781+ // std::cout<<std::to_string(l0)<<", "<<std::to_string(l1)<<std::endl;
782+ if (v>vg.getMaxVertex ()||w>vg.getMaxVertex ()) continue ;
783+ // std::cout<<"edge "<<v<<" "<<w<<std::endl;
784+
785+ if (l1-l0<=params.getMaxTimeGapComplete ()){
786+ completeGraph.insertEdge (v,w);
787+ completeScore.push_back (edgeCost);
788+ }
789+ }
790+ }
791+
792+
745793template <class T >
746794inline void CompleteStructure<T>::addEdgesFromMatrix(size_t time1,size_t time2,const py::array_t <double > inputMatrix){
747795
@@ -823,7 +871,7 @@ inline void CompleteStructure<T>::addEdgesFromFile(const std::string& fileName,P
823871 try {
824872 data.open (fileName);
825873 if (!data){
826- throw std::system_error (errno, std::system_category (), " failed to open " +fileName);
874+ throw std::system_error (errno, std::system_category (), " failed to open graph file " +fileName);
827875 }
828876
829877 std::getline (data, line);
0 commit comments