Skip to content

Commit

Permalink
add at() method
Browse files Browse the repository at this point in the history
  • Loading branch information
luk036 committed Jun 24, 2023
1 parent 1fe1a17 commit 0ee1b66
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option(INSTALL_ONLY "Enable for installation only" OFF)
# Note: update this to your new project's name and version
project(
XNetwork
VERSION 1.6.5
VERSION 1.6.6
LANGUAGES CXX
)

Expand Down
Binary file removed core
Binary file not shown.
6 changes: 5 additions & 1 deletion include/xnetwork/classes/coreviews.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ template <typename Atlas> class AtlasView {
return this->_atlas.at(key);
}

template <typename T> auto operator[](const T &key) -> auto & {
template <typename T> auto at(const T &key) const -> const auto & {
return this->_atlas.at(key);
}

template <typename T> auto operator[](const T &key) -> auto & {
return this->_atlas[key];
}

// auto copy( ) {
// return std::tuple{n: self[n].copy() for n : this->_atlas};
// }
Expand Down
10 changes: 6 additions & 4 deletions include/xnetwork/classes/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,11 @@ class Graph {
AtlasView({1: {}});
*/
auto operator[](const Node &n) const -> const auto & {
return this->adj()[n];
return this->adj().at(n);
}

auto at(const Node &n) const -> const auto & { return this->adj().at(n); }

auto operator[](const Node &n) -> auto & { return this->adj()[n]; }

/** A NodeView of the Graph as gra.nodes().
Expand Down Expand Up @@ -494,7 +496,7 @@ class Graph {
> len(gra);
3
*/
auto number_of_nodes() const { return this->_node.size(); }
auto number_of_nodes() const -> size_t { return this->_node.size(); }

// auto number_of_edges() const
// {
Expand Down Expand Up @@ -525,7 +527,7 @@ class Graph {
--------
number_of_nodes, order which are identical
*/
auto size() { return this->_node.size(); }
auto size() const -> size_t { return this->_node.size(); }

/** Return true if (the graph contains the node n.
Expand All @@ -540,7 +542,7 @@ class Graph {
> gra = nx.path_graph(3); // or DiGraph, MultiGraph, MultiDiGraph,
etc > gra.has_node(0); true
*/
auto has_node(const Node &n) { return this->_node.contains(n); }
auto has_node(const Node &n) const -> bool { return this->_node.contains(n); }

/** Add an edge between u and v.
Expand Down
2 changes: 1 addition & 1 deletion specific.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CPMAddPackage(

CPMAddPackage(
NAME Py2Cpp
GIT_TAG 1.4.4
GIT_TAG 1.4.6
GITHUB_REPOSITORY luk036/py2cpp
OPTIONS "INSTALL_ONLY YES" # create an installable target
)
Expand Down

0 comments on commit 0ee1b66

Please sign in to comment.