Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganizzation of Code #385

Merged
merged 7 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/PartitionExample/partition_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ int main() {
// std::cout << *cit_graph_ptr << std::endl;
std::cout << cit_graph_ptr->getEdgeSet().size() << std::endl;
std::cout << cit_graph_ptr->getNodeSet().size() << std::endl;
auto partitionedTwo = cit_graph_ptr->partitionGraph(
auto partitionedTwo = CXXGraph::Partitioning::Partitioner<int>::partitionGraph( *cit_graph_ptr,
CXXGraph::Partitioning::HDRF_ALG, 2, 1, 1, 1, 4);
std::cout << "end partition two" << std::endl;
auto partitionedFour = cit_graph_ptr->partitionGraph(
auto partitionedFour = CXXGraph::Partitioning::Partitioner<int>::partitionGraph( *cit_graph_ptr,
CXXGraph::Partitioning::HDRF_ALG, 4, 1, 1, 1, 4);
std::cout << "end partition four" << std::endl;
auto partitionedEight = cit_graph_ptr->partitionGraph(
auto partitionedEight = CXXGraph::Partitioning::Partitioner<int>::partitionGraph( *cit_graph_ptr,
CXXGraph::Partitioning::HDRF_ALG, 8, 1, 1, 1, 4);
std::cout << "end partition eight" << std::endl;
auto statsTwo = CXXGraph::Partitioning::getPartitionStats(partitionedTwo);
Expand Down
16 changes: 8 additions & 8 deletions include/CXXGraph/CXXGraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#define __CXXGRAPH_H__

#include "CXXGraph/CXXGraphConfig.h"
#include "CXXGraph/Edge/DirectedEdge.hpp"
#include "CXXGraph/Edge/DirectedWeightedEdge.hpp"
#include "CXXGraph/Edge/Edge.hpp"
#include "CXXGraph/Edge/UndirectedEdge.hpp"
#include "CXXGraph/Edge/UndirectedWeightedEdge.hpp"
#include "CXXGraph/Edge/Weighted.hpp"
#include "CXXGraph/Graph/Graph.hpp"
#include "CXXGraph/Node/Node.hpp"
#include "CXXGraph/Edge/DirectedEdge.h"
#include "CXXGraph/Edge/DirectedWeightedEdge.h"
#include "CXXGraph/Edge/Edge.h"
#include "CXXGraph/Edge/UndirectedEdge.h"
#include "CXXGraph/Edge/UndirectedWeightedEdge.h"
#include "CXXGraph/Edge/Weighted.h"
#include "CXXGraph/Graph/Graph.h"
#include "CXXGraph/Node/Node.h"
#include "CXXGraph/Partitioning/CoordinatedPartitionState.hpp"
#include "CXXGraph/Partitioning/CoordinatedRecord.hpp"
#include "CXXGraph/Partitioning/EBV.hpp"
Expand Down
27 changes: 27 additions & 0 deletions include/CXXGraph/Edge/DirectedEdge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/***********************************************************/
/*** ______ ____ ______ _ ***/
/*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/
/*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/
/*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/
/*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/
/*** |_| ***/
/***********************************************************/
/*** Header-Only C++ Library for Graph ***/
/*** Representation and Algorithms ***/
/***********************************************************/
/*** Author: ZigRazor ***/
/*** E-Mail: zigrazor@gmail.com ***/
/***********************************************************/
/*** Collaboration: ----------- ***/
/***********************************************************/
/*** License: AGPL v3.0 ***/
/***********************************************************/

#ifndef __CXXGRAPH_DIRECTEDEDGE_H__
#define __CXXGRAPH_DIRECTEDEDGE_H__

#pragma once

#include "DirectedEdge_impl.hpp"

#endif // __CXXGRAPH_DIRECTEDEDGE_H__
69 changes: 69 additions & 0 deletions include/CXXGraph/Edge/DirectedEdge_decl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/***********************************************************/
/*** ______ ____ ______ _ ***/
/*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/
/*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/
/*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/
/*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/
/*** |_| ***/
/***********************************************************/
/*** Header-Only C++ Library for Graph ***/
/*** Representation and Algorithms ***/
/***********************************************************/
/*** Author: ZigRazor ***/
/*** E-Mail: zigrazor@gmail.com ***/
/***********************************************************/
/*** Collaboration: ----------- ***/
/***********************************************************/
/*** License: AGPL v3.0 ***/
/***********************************************************/

#ifndef __CXXGRAPH_DIRECTEDEDGE_DECL_H__
#define __CXXGRAPH_DIRECTEDEDGE_DECL_H__

#pragma once

#include "Edge_decl.h"

namespace CXXGraph {
// Smart pointers alias
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;

template <typename T>
class UndirectedEdge;

template <typename T>
class DirectedEdge;
// ostream operator
template <typename T>
std::ostream &operator<<(std::ostream &o, const DirectedEdge<T> &edge);
template <typename T>
class DirectedEdge : public Edge<T> {
public:
DirectedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2);
DirectedEdge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2);
DirectedEdge(const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair);
DirectedEdge(const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair);
DirectedEdge(const Edge<T> &edge);
virtual ~DirectedEdge() = default;
const Node<T> &getFrom() const;
const Node<T> &getTo() const;
const std::optional<bool> isDirected() const override;
const std::optional<bool> isWeighted() const override;
// operator
explicit operator UndirectedEdge<T>() const {
return UndirectedEdge<T>(Edge<T>::getId(), Edge<T>::getNodePair());
}

friend std::ostream &operator<< <>(std::ostream &os,
const DirectedEdge<T> &edge);
};
} // namespace CXXGraph

#endif // __CXXGRAPH_DIRECTEDEDGE_H__
49 changes: 5 additions & 44 deletions include/CXXGraph/Edge/DirectedEdge.hpp → include/CXXGraph/Edge/DirectedEdge_impl.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,18 @@
/*** License: AGPL v3.0 ***/
/***********************************************************/

#ifndef __CXXGRAPH_DIRECTEDEDGE_H__
#define __CXXGRAPH_DIRECTEDEDGE_H__
#ifndef __CXXGRAPH_DIRECTEDEDGE_IMPL_H__
#define __CXXGRAPH_DIRECTEDEDGE_IMPL_H__

#pragma once

#include "Edge.hpp"
#include "DirectedEdge_decl.h"

namespace CXXGraph {
// Smart pointers alias
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;


using std::make_unique;
using std::make_shared;

template <typename T>
class UndirectedEdge;

template <typename T>
class DirectedEdge;
// ostream operator
template <typename T>
std::ostream &operator<<(std::ostream &o, const DirectedEdge<T> &edge);
template <typename T>
class DirectedEdge : public Edge<T> {
public:
DirectedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2);
DirectedEdge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2);
DirectedEdge(const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair);
DirectedEdge(const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair);
DirectedEdge(const Edge<T> &edge);
virtual ~DirectedEdge() = default;
const Node<T> &getFrom() const;
const Node<T> &getTo() const;
const std::optional<bool> isDirected() const override;
const std::optional<bool> isWeighted() const override;
// operator
explicit operator UndirectedEdge<T>() const {
return UndirectedEdge<T>(Edge<T>::getId(), Edge<T>::getNodePair());
}

friend std::ostream &operator<< <>(std::ostream &os,
const DirectedEdge<T> &edge);
};

template <typename T>
DirectedEdge<T>::DirectedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2)
Expand Down Expand Up @@ -122,4 +83,4 @@ std::ostream &operator<<(std::ostream &os, const DirectedEdge<T> &edge) {
}
} // namespace CXXGraph

#endif // __CXXGRAPH_DIRECTEDEDGE_H__
#endif // __CXXGRAPH_DIRECTEDEDGE_IMPL_H__
26 changes: 26 additions & 0 deletions include/CXXGraph/Edge/DirectedWeightedEdge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/***********************************************************/
/*** ______ ____ ______ _ ***/
/*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/
/*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/
/*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/
/*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/
/*** |_| ***/
/***********************************************************/
/*** Header-Only C++ Library for Graph ***/
/*** Representation and Algorithms ***/
/***********************************************************/
/*** Author: ZigRazor ***/
/*** E-Mail: zigrazor@gmail.com ***/
/***********************************************************/
/*** Collaboration: ----------- ***/
/***********************************************************/
/*** License: AGPL v3.0 ***/
/***********************************************************/
#ifndef __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_H__
#define __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_H__

#pragma once

#include "DirectedWeightedEdge_impl.hpp"

#endif // __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_H__
79 changes: 79 additions & 0 deletions include/CXXGraph/Edge/DirectedWeightedEdge_decl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/***********************************************************/
/*** ______ ____ ______ _ ***/
/*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/
/*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/
/*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/
/*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/
/*** |_| ***/
/***********************************************************/
/*** Header-Only C++ Library for Graph ***/
/*** Representation and Algorithms ***/
/***********************************************************/
/*** Author: ZigRazor ***/
/*** E-Mail: zigrazor@gmail.com ***/
/***********************************************************/
/*** Collaboration: ----------- ***/
/***********************************************************/
/*** License: AGPL v3.0 ***/
/***********************************************************/
#ifndef __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_DECL_H__
#define __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_DECL_H__

#pragma once

#include "DirectedEdge_decl.h"
#include "Weighted.h"

namespace CXXGraph {
// Smart pointers alias
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;

// Foward Declaration
template <typename T>
class UndirectedWeightedEdge;

template <typename T>
class DirectedWeightedEdge;

// ostream operator
template <typename T>
std::ostream &operator<<(std::ostream &o, const DirectedWeightedEdge<T> &edge);

template <typename T>
class DirectedWeightedEdge : public DirectedEdge<T>, public Weighted {
public:
DirectedWeightedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2, const double weight);
DirectedWeightedEdge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2, const double weight);
DirectedWeightedEdge(
const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair,
const double weight);
DirectedWeightedEdge(
const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair,
const double weight);
DirectedWeightedEdge(const DirectedEdge<T> &edge, const double weight);
DirectedWeightedEdge(const Edge<T> &edge, const double weight);
DirectedWeightedEdge(const DirectedEdge<T> &edge);
DirectedWeightedEdge(const Edge<T> &edge);
DirectedWeightedEdge(const UndirectedWeightedEdge<T> &edge);
virtual ~DirectedWeightedEdge() = default;
const std::optional<bool> isWeighted() const override;
// operator
explicit operator UndirectedWeightedEdge<T>() const {
return UndirectedWeightedEdge<T>(Edge<T>::getId(), Edge<T>::getNodePair(),
Weighted::getWeight());
}

friend std::ostream &operator<< <>(std::ostream &os,
const DirectedWeightedEdge<T> &edge);
};

} // namespace CXXGraph

#endif // __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_DECL_H__
58 changes: 5 additions & 53 deletions ...de/CXXGraph/Edge/DirectedWeightedEdge.hpp → ...XGraph/Edge/DirectedWeightedEdge_impl.hpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,67 +16,19 @@
/***********************************************************/
/*** License: AGPL v3.0 ***/
/***********************************************************/
#ifndef __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_H__
#define __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_H__
#ifndef __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_IMPL_H__
#define __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_IMPL_H__

#pragma once

#include "DirectedEdge.hpp"
#include "Weighted.hpp"
#include "DirectedWeightedEdge_decl.h"
#include "Weighted.h"

namespace CXXGraph {
// Smart pointers alias
template <typename T>
using unique = std::unique_ptr<T>;
template <typename T>
using shared= std::shared_ptr<T>;

using std::make_unique;
using std::make_shared;

// Foward Declaration
template <typename T>
class UndirectedWeightedEdge;

template <typename T>
class DirectedWeightedEdge;

// ostream operator
template <typename T>
std::ostream &operator<<(std::ostream &o, const DirectedWeightedEdge<T> &edge);

template <typename T>
class DirectedWeightedEdge : public DirectedEdge<T>, public Weighted {
public:
DirectedWeightedEdge(const CXXGraph::id_t id, const Node<T> &node1,
const Node<T> &node2, const double weight);
DirectedWeightedEdge(const CXXGraph::id_t id, shared<const Node<T>> node1,
shared<const Node<T>> node2, const double weight);
DirectedWeightedEdge(
const CXXGraph::id_t id,
const std::pair<const Node<T> *, const Node<T> *> &nodepair,
const double weight);
DirectedWeightedEdge(
const CXXGraph::id_t id,
const std::pair<shared<const Node<T>>, shared<const Node<T>>> &nodepair,
const double weight);
DirectedWeightedEdge(const DirectedEdge<T> &edge, const double weight);
DirectedWeightedEdge(const Edge<T> &edge, const double weight);
DirectedWeightedEdge(const DirectedEdge<T> &edge);
DirectedWeightedEdge(const Edge<T> &edge);
DirectedWeightedEdge(const UndirectedWeightedEdge<T> &edge);
virtual ~DirectedWeightedEdge() = default;
const std::optional<bool> isWeighted() const override;
// operator
explicit operator UndirectedWeightedEdge<T>() const {
return UndirectedWeightedEdge<T>(Edge<T>::getId(), Edge<T>::getNodePair(),
Weighted::getWeight());
}

friend std::ostream &operator<< <>(std::ostream &os,
const DirectedWeightedEdge<T> &edge);
};

template <typename T>
DirectedWeightedEdge<T>::DirectedWeightedEdge(const CXXGraph::id_t id,
const Node<T> &node1,
Expand Down Expand Up @@ -144,4 +96,4 @@ std::ostream &operator<<(std::ostream &os,

} // namespace CXXGraph

#endif // __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_H__
#endif // __CXXGRAPH_DIRECTEDWEIGHTEDEDGE_IMPL_H__
Loading
Loading