forked from ZigRazor/CXXGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement generic addNodes and addEdges (ZigRazor#363)
* Add header file containig type traits for edges and nodes * Add `is_node_v` and `is_edge_v` templates * Implement addNodes and addEdges methods * Add tests for addEdges * Add tests for addNodes * Document addNodes and addEdges methods * Specify different type trait for Node and Edge pointers, is_node_ptr and is_edge_ptr
- Loading branch information
Showing
3 changed files
with
444 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/***********************************************************/ | ||
/*** ______ ____ ______ _ ***/ | ||
/*** / ___\ \/ /\ \/ / ___|_ __ __ _ _ __ | |__ ***/ | ||
/*** | | \ / \ / | _| '__/ _` | '_ \| '_ \ ***/ | ||
/*** | |___ / \ / \ |_| | | | (_| | |_) | | | | ***/ | ||
/*** \____/_/\_\/_/\_\____|_| \__,_| .__/|_| |_| ***/ | ||
/*** |_| ***/ | ||
/***********************************************************/ | ||
/*** Header-Only C++ Library for Graph ***/ | ||
/*** Representation and Algorithms ***/ | ||
/***********************************************************/ | ||
/*** Author: ZigRazor ***/ | ||
/*** E-Mail: zigrazor@gmail.com ***/ | ||
/***********************************************************/ | ||
/*** Collaboration: ----------- ***/ | ||
/***********************************************************/ | ||
/*** License: AGPL v3.0 ***/ | ||
/***********************************************************/ | ||
|
||
#ifndef __CXXGRAPH_TYPE_TRAITS__ | ||
#define __CXXGRAPH_TYPE_TRAITS__ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#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/Node/Node.hpp" | ||
|
||
namespace CXXGraph { | ||
|
||
// define is_node type trait for Nodes, Nodes pointers and shared pointers | ||
template <typename T> | ||
struct is_node : std::false_type {}; | ||
|
||
template <typename T> | ||
struct is_node<Node<T>> : std::true_type {}; | ||
|
||
// define is_node_ptr type trait for Node pointers and shared pointers | ||
template <typename T> | ||
struct is_node_ptr : std::false_type {}; | ||
|
||
template <typename T> | ||
struct is_node_ptr<const Node<T>*> : std::true_type {}; | ||
|
||
template <typename T> | ||
struct is_node_ptr<shared<const Node<T>>> : std::true_type {}; | ||
|
||
template <typename T> | ||
inline constexpr bool is_node_ptr_v = is_node<T>::value; | ||
|
||
// define is_edge type trait for Edges | ||
template <typename T> | ||
struct is_edge : std::false_type {}; | ||
|
||
template <typename T> | ||
struct is_edge<Edge<T>> : std::true_type {}; | ||
|
||
// define is_edge_ptr type trait for Edge pointers and shared pointers | ||
template <typename T> | ||
struct is_edge_ptr : std::false_type {}; | ||
|
||
template <typename T> | ||
struct is_edge_ptr<const Edge<T>*> : std::true_type {}; | ||
|
||
template <typename T> | ||
struct is_edge_ptr<shared<const Edge<T>>> : std::true_type {}; | ||
|
||
template <typename T> | ||
inline constexpr bool is_edge_ptr_v = is_edge<T>::value; | ||
} // namespace CXXGraph | ||
|
||
#endif |
Oops, something went wrong.