20 #ifndef __CXXGRAPH_GRAPH_TS_H__
21 #define __CXXGRAPH_GRAPH_TS_H__
25 #include "Graph/Graph.hpp"
47 const std::list<const Edge<T> *> &
getEdgeSet()
const override;
74 void removeEdge(
unsigned long long edgeId)
override;
83 const std::list<const Node<T> *>
getNodeSet()
const override;
93 const std::optional<const Edge<T> *>
getEdge(
unsigned long long edgeId)
const override;
231 int writeToFile(InputOutputFormat format = InputOutputFormat::STANDARD_CSV,
const std::string &workingDir =
".",
const std::string &OFileName =
"graph",
bool compress =
false,
bool writeNodeFeat =
false,
bool writeEdgeWeight =
false)
const override;
246 int readFromFile(InputOutputFormat format = InputOutputFormat::STANDARD_CSV,
const std::string &workingDir =
".",
const std::string &OFileName =
"graph",
bool compress =
false,
bool readNodeFeat =
false,
bool readEdgeWeight =
false)
override;
257 PartitionMap<T>
partitionGraph(PARTITIONING::PartitionAlgorithm algorithm,
unsigned int numberOfPartitions,
double param1 = 0.0,
double param2 = 0.0,
double param3 = 0.0,
unsigned int numberOfthreads = std::thread::hardware_concurrency())
const override;
260 template <
typename T>
263 template <
typename T>
264 Graph_TS<T>::Graph_TS(
const Graph<T> &graph) : Graph<T>(graph), ThreadSafe() {}
266 template <
typename T>
269 std::lock_guard<std::mutex> lock(mutex);
273 template <
typename T>
281 template <
typename T>
289 template <
typename T>
297 template <
typename T>
306 template <
typename T>
315 template <
typename T>
324 template <
typename T>
333 template <
typename T>
342 template <
typename T>
351 template <
typename T>
360 template <
typename T>
369 template <
typename T>
378 template <
typename T>
387 template <
typename T>
396 template <
typename T>
405 template <
typename T>
406 int Graph_TS<T>::writeToFile(InputOutputFormat format,
const std::string &workingDir,
const std::string &OFileName,
bool compress,
bool writeNodeFeat,
bool writeEdgeWeight)
const
409 auto result =
Graph<T>::writeToFile(format, workingDir, OFileName, compress, writeNodeFeat, writeEdgeWeight);
414 template <
typename T>
415 int Graph_TS<T>::readFromFile(InputOutputFormat format,
const std::string &workingDir,
const std::string &OFileName,
bool compress,
bool readNodeFeat,
bool readEdgeWeight)
418 auto result =
Graph<T>::readFromFile(format, workingDir, OFileName, compress, readNodeFeat, readEdgeWeight);
423 template <
typename T>
424 PartitionMap<T>
Graph_TS<T>::partitionGraph(PARTITIONING::PartitionAlgorithm algorithm,
unsigned int numberOfPartitions,
double param1,
double param2,
double param3,
unsigned int numberOfthreads)
const
Class that implement the Thread Safe Graph.
Definition: Graph_TS.hpp:33
const std::list< const Node< T > * > getNodeSet() const override
Function that return the Node Set of the Graph Note: Thread Safe.
Definition: Graph_TS.hpp:298
void setEdgeSet(std::list< const Edge< T > * > &edgeSet) override
Function set the Edge Set of the Graph Note: Thread Safe.
Definition: Graph_TS.hpp:274
bool isDirectedGraph() const override
This function checks if a graph is directed Note: Thread Safe.
Definition: Graph_TS.hpp:388
const DijkstraResult dijkstra(const Node< T > &source, const Node< T > &target) const override
Function runs the dijkstra algorithm for some source node and target node in the graph and returns th...
Definition: Graph_TS.hpp:325
PartitionMap< T > partitionGraph(PARTITIONING::PartitionAlgorithm algorithm, unsigned int numberOfPartitions, double param1=0.0, double param2=0.0, double param3=0.0, unsigned int numberOfthreads=std::thread::hardware_concurrency()) const override
This function partition a graph in a set of partitions Note: Thread Safe.
Definition: Graph_TS.hpp:424
void removeEdge(unsigned long long edgeId) override
Function remove an Edge from the Graph Edge Set Note: Thread Safe.
Definition: Graph_TS.hpp:290
int writeToFile(InputOutputFormat format=InputOutputFormat::STANDARD_CSV, const std::string &workingDir=".", const std::string &OFileName="graph", bool compress=false, bool writeNodeFeat=false, bool writeEdgeWeight=false) const override
This function write the graph in an output file Note: Thread Safe.
Definition: Graph_TS.hpp:406
void addEdge(const Edge< T > *edge) override
Function add an Edge to the Graph Edge Set Note: Thread Safe.
Definition: Graph_TS.hpp:282
bool isCyclicDirectedGraphBFS() const override
This function uses BFS to check for cycle in the graph. Pay Attention, this function work only with d...
Definition: Graph_TS.hpp:379
int readFromFile(InputOutputFormat format=InputOutputFormat::STANDARD_CSV, const std::string &workingDir=".", const std::string &OFileName="graph", bool compress=false, bool readNodeFeat=false, bool readEdgeWeight=false) override
This function read the graph from an input file Note: Thread Safe.
Definition: Graph_TS.hpp:415
const std::vector< Node< T > > breadth_first_search(const Node< T > &start) const override
Function performs the breadth first search algorithm over the graph Note: Thread Safe.
Definition: Graph_TS.hpp:352
const std::optional< const Edge< T > * > getEdge(unsigned long long edgeId) const override
Function that return an Edge with specific ID if Exist in the Graph Note: Thread Safe.
Definition: Graph_TS.hpp:307
const BellmanFordResult bellmanford(const Node< T > &source, const Node< T > &target) const override
Function runs the bellmanford algorithm for some source node and target node in the graph and returns...
Definition: Graph_TS.hpp:334
const std::list< const Edge< T > * > & getEdgeSet() const override
Function that return the Edge set of the Graph Note: Thread Safe.
Definition: Graph_TS.hpp:267
const std::vector< Node< T > > depth_first_search(const Node< T > &start) const override
Function performs the depth first search algorithm over the graph Note: Thread Safe.
Definition: Graph_TS.hpp:361
const FWResult floydWarshall() const override
Function runs the floyd-Warshall algorithm for every node in the graph and returns the shortest dista...
Definition: Graph_TS.hpp:343
const DialResult dial(const Node< T > &source, int maxWeight) const override
This function write the graph in an output file Note: Thread Safe.
Definition: Graph_TS.hpp:397
bool isCyclicDirectedGraphDFS() const override
This function uses DFS to check for cycle in the graph. Pay Attention, this function work only with d...
Definition: Graph_TS.hpp:370
const AdjacencyMatrix< T > getAdjMatrix() const override
This function generate a list of adjacency matrix with every element of the matrix contain the node w...
Definition: Graph_TS.hpp:316
Class that implement the Graph. ( This class is not Thread Safe )
Definition: Graph.hpp:79
virtual const FWResult floydWarshall() const
Function runs the floyd-warshall algorithm and returns the shortest distance of all pair of nodes....
Definition: Graph.hpp:1147
virtual const std::vector< Node< T > > depth_first_search(const Node< T > &start) const
Function performs the depth first search algorithm over the graph Note: No Thread Safe.
Definition: Graph.hpp:1521
virtual const std::list< const Edge< T > * > & getEdgeSet() const
Function that return the Edge set of the Graph Note: No Thread Safe.
Definition: Graph.hpp:429
virtual bool isCyclicDirectedGraphBFS() const
This function uses BFS to check for cycle in the graph. Pay Attention, this function work only with d...
Definition: Graph.hpp:1686
virtual int writeToFile(InputOutputFormat format=InputOutputFormat::STANDARD_CSV, const std::string &workingDir=".", const std::string &OFileName="graph", bool compress=false, bool writeNodeFeat=false, bool writeEdgeWeight=false) const
This function write the graph in an output file Note: No Thread Safe.
Definition: Graph.hpp:1954
virtual bool isDirectedGraph() const
This function checks if a graph is directed Note: No Thread Safe.
Definition: Graph.hpp:1755
virtual const std::optional< const Edge< T > * > getEdge(unsigned long long edgeId) const
Function that return an Edge with specific ID if Exist in the Graph Note: No Thread Safe.
Definition: Graph.hpp:490
virtual const DialResult dial(const Node< T > &source, int maxWeight) const
This function write the graph in an output file Note: No Thread Safe.
Definition: Graph.hpp:1787
virtual PartitionMap< T > partitionGraph(PARTITIONING::PartitionAlgorithm algorithm, unsigned int numberOfPartitions, double param1=0.0, double param2=0.0, double param3=0.0, unsigned int numberOfthreads=std::thread::hardware_concurrency()) const
This function partition a graph in a set of partitions Note: No Thread Safe.
Definition: Graph.hpp:2067
virtual const DijkstraResult dijkstra(const Node< T > &source, const Node< T > &target) const
Function runs the dijkstra algorithm for some source node and target node in the graph and returns th...
Definition: Graph.hpp:923
virtual bool isCyclicDirectedGraphDFS() const
This function uses DFS to check for cycle in the graph. Pay Attention, this function work only with d...
Definition: Graph.hpp:1553
virtual void addEdge(const Edge< T > *edge)
Function add an Edge to the Graph Edge Set Note: No Thread Safe.
Definition: Graph.hpp:449
virtual int readFromFile(InputOutputFormat format=InputOutputFormat::STANDARD_CSV, const std::string &workingDir=".", const std::string &OFileName="graph", bool compress=false, bool readNodeFeat=false, bool readEdgeWeight=false)
This function read the graph from an input file Note: No Thread Safe.
Definition: Graph.hpp:2015
virtual void removeEdge(unsigned long long edgeId)
Function remove an Edge from the Graph Edge Set Note: No Thread Safe.
Definition: Graph.hpp:459
virtual const AdjacencyMatrix< T > getAdjMatrix() const
This function generate a list of adjacency matrix with every element of the matrix contain the node w...
Definition: Graph.hpp:897
virtual const std::list< const Node< T > * > getNodeSet() const
Function that return the Node Set of the Graph Note: No Thread Safe.
Definition: Graph.hpp:470
virtual const BellmanFordResult bellmanford(const Node< T > &source, const Node< T > &target) const
Function runs the bellman-ford algorithm for some source node and target node in the graph and return...
Definition: Graph.hpp:1039
virtual const std::vector< Node< T > > breadth_first_search(const Node< T > &start) const
Function performs the breadth first search algorithm over the graph Note: No Thread Safe.
Definition: Graph.hpp:1481
virtual void setEdgeSet(std::list< const Edge< T > * > &edgeSet)
Function set the Edge Set of the Graph Note: No Thread Safe.
Definition: Graph.hpp:435
Definition: ThreadSafe.hpp:30
Struct that contains the information about Dijsktra's Algorithm results.
Definition: Typedef.hpp:79
Struct that contains the information about Dijsktra's Algorithm results.
Definition: Typedef.hpp:130
Struct that contains the information about Dijsktra's Algorithm results.
Definition: Typedef.hpp:70
Struct that contains the information about Floyd-Warshall Algorithm results.
Definition: Typedef.hpp:110