.. _program_listing_file_src_sparsebase_object_object.cc: Program Listing for File object.cc ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/sparsebase/object/object.cc``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "object.h" #include #include "sparsebase/format/format.h" #include "sparsebase/format/format_order_one.h" #include "sparsebase/format/format_order_two.h" #include "sparsebase/io/edge_list_reader.h" #include "sparsebase/io/mtx_reader.h" namespace sparsebase::object { Object::~Object(){}; template AbstractObject::~AbstractObject(){}; template AbstractObject::AbstractObject() : connectivity_(nullptr, format::BlankDeleter()){}; template AbstractObject::AbstractObject( AbstractObject &&rhs) : connectivity_(std::move(rhs.connectivity_)){}; template AbstractObject::AbstractObject( const AbstractObject &rhs) : connectivity_((format::Format *)rhs.connectivity_->Clone(), format::BlankDeleter()){}; template format::Format *AbstractObject::get_connectivity() const { return connectivity_.get(); } template bool AbstractObject::ConnectivityIsOwned() const { return (connectivity_.get_deleter().target_type() != typeid(format::BlankDeleter)); } template format::Format * AbstractObject::release_connectivity() { auto ptr = connectivity_.release(); connectivity_ = std::unique_ptr>( ptr, format::BlankDeleter()); return ptr; } template void AbstractObject::set_connectivity( format::Format *conn, bool own) { if (own) connectivity_ = std::unique_ptr>( conn, format::Deleter()); else connectivity_ = std::unique_ptr>( conn, format::BlankDeleter()); } template Graph::Graph( Graph &&rhs) { this->set_connectivity(rhs.release_connectivity(), true); InitializeInfoFromConnection(); rhs.set_connectivity(nullptr, false); } template Graph::Graph( const Graph &rhs) { this->set_connectivity( static_cast(rhs.connectivity_->Clone()), true); InitializeInfoFromConnection(); } template Graph &Graph::operator=( const Graph &rhs) { this->set_connectivity( static_cast(rhs.connectivity_->Clone()), true); InitializeInfoFromConnection(); return *this; } template Graph::Graph(format::Format *connectivity) { // this->connectivity_ = connectivity; this->set_connectivity(connectivity, true); this->VerifyStructure(); InitializeInfoFromConnection(); } template void Graph::ReadConnectivityToCOO( const io::ReadsCOO &reader) { this->set_connectivity(reader.ReadCOO(), true); this->VerifyStructure(); InitializeInfoFromConnection(); // std::cout << "dimensions " << this->connectivity_->get_dimensions()[0] << // ", " // << this->connectivity_->get_dimensions()[1] << std::endl; } template void Graph::ReadConnectivityToCSR( const io::ReadsCSR &reader) { this->set_connectivity(reader.ReadCSR(), true); this->VerifyStructure(); InitializeInfoFromConnection(); } template void Graph::ReadConnectivityFromEdgelistToCSR( std::string filename) { io::EdgeListReader reader(filename, false, false, false, true, true); this->set_connectivity(reader.ReadCSR(), true); this->VerifyStructure(); InitializeInfoFromConnection(); } template void Graph::ReadConnectivityFromMTXToCOO( std::string filename) { io::MTXReader reader(filename); this->set_connectivity(reader.ReadCOO(), true); this->VerifyStructure(); InitializeInfoFromConnection(); } template Graph::Graph() {} template void Graph::InitializeInfoFromConnection() { auto dimensions = this->connectivity_->get_dimensions(); n_ = dimensions[0]; m_ = this->connectivity_->get_num_nnz(); } template Graph::~Graph(){}; template void Graph::VerifyStructure() { // check order if (this->connectivity_->get_order() != 2) throw -1; // check dimensions } #if !defined(_HEADER_ONLY) #include "init/object.inc" #endif // template // class TemporalGraph : public AbstractSparseObject{ // public: // TemporalGraph(SparseFormat * _connectivity){ // // init temporal graph // } // TemporalGraph(Reader * r){ // // init temporal graph from file // } // virtual ~TemporalGraph(){}; // void VerifyStructure(){ // // check order // if (this->connectivity->get_order() != 2) //throw error // // check dimensions // } // VertexID n; // NumEdges m; // // ... // }; } // namespace sparsebase::object