Skip to content

Commit

Permalink
remove ig prefix from names, refs #3
Browse files Browse the repository at this point in the history
  • Loading branch information
szhorvat committed Jul 18, 2024
1 parent 0a64adf commit 6687228
Show file tree
Hide file tree
Showing 17 changed files with 184 additions and 184 deletions.
20 changes: 10 additions & 10 deletions examples/ex_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ using namespace ig;

int main() {

// igRealVec is a RAII wrapper to igraph_vector_t.
// RealVec is a RAII wrapper to igraph_vector_t.
// When it goes out of scope, it is properly destroyed.
// igRealVec is a convenience name for igVec<igraph_real_t>.
igRealVec v;
// RealVec is a convenience name for Vec<igraph_real_t>.
RealVec v;

// The initial size is zero.
std::cout << v.size() << std::endl;

// igVec<XXX> is implicitly convertible to the corresponding igraph_vector_XXX_t * pointer.
// Vec<XXX> is implicitly convertible to the corresponding igraph_vector_XXX_t * pointer.
igraph_vector_resize(v, 10);
std::cout << v.size() << std::endl;

// igVec<> has STL-compatible convenience member functions for common operations.
// Vec<> has STL-compatible convenience member functions for common operations.
// These generally call the corresponding igraph function.
v.resize(5);
std::cout << v.size() << std::endl;

// Note that igRealVec::resize() has a behaviour identical to that of igraph_vector_resize().
// Note that RealVec::resize() has a behaviour identical to that of igraph_vector_resize().
// It does not set the newly added elements to zero, but we can easily do this using
// igraph's standard facilities.
igraph_vector_null(v);
Expand All @@ -45,7 +45,7 @@ int main() {
// Use standard C++ features to fill the vector with an increasing sequence.
std::iota(v.begin(), v.end(), 3);

// See ex_vector_print.hpp for stream support for igVec.
// See ex_vector_print.hpp for stream support for Vec.
std::cout << v << std::endl;

// Use igraph features to fill the vector with an increasing sequence.
Expand All @@ -57,16 +57,16 @@ int main() {
std::cout << v << std::endl;

// Create an integer list initializer.
// igIntVec is a convenience alias to igVec<igraph_integer_t>.
igIntVec iv = {4, 3, 0, 9, -3};
// IntVec is a convenience alias to Vec<igraph_integer_t>.
IntVec iv = {4, 3, 0, 9, -3};
std::cout << "Original: " << iv << std::endl;

// Sort it using STL facilities and print it.
std::stable_sort(iv.begin(), iv.end());
std::cout << "Sorted: " << iv << std::endl;

// Create a boolean vector using a list initializer and print it.
igBoolVec bv = {true, false, true, false};
BoolVec bv = {true, false, true, false};
std::cout << "Boolean vector: " << bv << std::endl;

return 0;
Expand Down
12 changes: 6 additions & 6 deletions examples/ex_decompose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
using namespace ig;

// Helper function to print a graph.
std::ostream & operator << (std::ostream &out, const igGraph &g) {
std::ostream & operator << (std::ostream &out, const Graph &g) {
out << "directed: " << (g.is_directed() ? "true" : "false") << std::endl;
out << "vcount: " << g.vcount() << std::endl;

igIntVec edges;
IntVec edges;
igraph_edges(g, igraph_ess_all(IGRAPH_EDGEORDER_ID), edges);
out << "edges: " << edges << std::endl;
return out;
Expand All @@ -21,10 +21,10 @@ std::ostream & operator << (std::ostream &out, const igGraph &g) {
int main() {

// Create a directed graph from its edge list.
igGraph g(igIntVec{0,1, 1,2, 3,4, 5,6}, 9, IGRAPH_DIRECTED);
Graph g(IntVec{0,1, 1,2, 3,4, 5,6}, 9, IGRAPH_DIRECTED);

// igGraphList is a wrapper for igraph_graph_list_t.
igGraphList list;
// GraphList is a wrapper for igraph_graph_list_t.
GraphList list;

// Decompose the graph into its weakly connected components.
igraph_decompose(g, list, IGRAPH_WEAK, -1, -1);
Expand All @@ -36,7 +36,7 @@ int main() {

// Reverse sort the graph list.
std::sort(list.begin(), list.end(),
[](const igGraph &a, const igGraph &b) { return a.vcount() < b.vcount(); });
[](const Graph &a, const Graph &b) { return a.vcount() < b.vcount(); });

// The two smallest components are the same graph because they are both singletons.
// Note that the == operator compares labelled graphs without attributes,
Expand Down
12 changes: 6 additions & 6 deletions examples/ex_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ using namespace ig;
int main() {

// igraph's default error handler aborts the program on error. We can turn
// off this behaviour, and convert error codes to exceptions using igCheck().
// off this behaviour, and convert error codes to exceptions using check().
igraph_set_error_handler(igraph_error_handler_printignore);

try {
// Trying to construct a graph from invalid vertex IDs.
igGraph g{igIntVec{-1,0, 0,1}};
Graph g{IntVec{-1,0, 0,1}};
} catch (const std::exception &ex) {
std::cerr << "Caught exception: " << ex.what() << std::endl;
}

try {
// Using invalid (negative) weights in a betweennes calculation.
igGraph g{igIntVec{0,1, 1,2}};
igRealVec weights = {1.0, -2.0};
igRealVec betweenness;
Graph g{IntVec{0,1, 1,2}};
RealVec weights = {1.0, -2.0};
RealVec betweenness;

igCheck(igraph_betweenness(g, betweenness, igraph_vss_all(), IGRAPH_DIRECTED, weights));
check(igraph_betweenness(g, betweenness, igraph_vss_all(), IGRAPH_DIRECTED, weights));
} catch (const std::exception &ex) {
std::cerr << "Caught exception: " << ex.what() << std::endl;
}
Expand Down
10 changes: 5 additions & 5 deletions examples/ex_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ int main() {
// Basic graph handling example.
{
// Create a graph from an edge list.
const igGraph g(igIntVec{0,1, 0,2, 2,3});
const Graph g(IntVec{0,1, 0,2, 2,3});
std::cout << "Vertex count: " << g.vcount() << ", edge count: " << g.ecount() << std::endl;

// Print its degrees.
igIntVec deg;
IntVec deg;
igraph_degree(g, deg, igraph_vss_all(), IGRAPH_ALL, IGRAPH_LOOPS);
std::cout << "Degrees: " << deg << std::endl;

Expand All @@ -25,7 +25,7 @@ int main() {
std::cout << "Has loops? " << (g.has_loop() ? "Yes" : "No") << std::endl;

// Prints its adjacency matrix.
igRealMat am;
RealMat am;
igraph_get_adjacency(g, am, IGRAPH_GET_ADJACENCY_BOTH, nullptr, IGRAPH_LOOPS_TWICE);
std::cout << "Adjacency matrix:" << std::endl;
igraph_matrix_print(am);
Expand All @@ -39,10 +39,10 @@ int main() {

// NOTE! Here 'g' "captures" 'ig', i.e. takes ownership of it,
// and will destroy it when it goes out of scope.
const igGraph g(igCapture(ig));
const Graph g(Capture(ig));

// Compute and print the closeness centrality.
igRealVec closeness;
RealVec closeness;
igraph_closeness(g, closeness, nullptr, nullptr, igraph_vss_all(), IGRAPH_ALL, nullptr, true);

std::cout << "Closeness: " << closeness << std::endl;
Expand Down
10 changes: 5 additions & 5 deletions examples/ex_igraph_tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ int main() {
igraph_rng_seed(igraph_rng_default(), 42); // seed RNG before first use

igraph_t igraph;
igraph_square_lattice(&igraph, igIntVec({30,30}),
igraph_square_lattice(&igraph, IntVec({30,30}),
0, IGRAPH_UNDIRECTED,
/* mutual= */ false, igBoolVec({true, true}));
igGraph graph(igCapture(igraph));
/* mutual= */ false, BoolVec({true, true}));
Graph graph(Capture(igraph));

igraph_real_t avg_path_len;
igraph_average_path_length(graph, &avg_path_len, nullptr, IGRAPH_UNDIRECTED, /* unconn= */ true);
std::cout << "Average path length (lattice): " << avg_path_len << std::endl;

igIntVec edges(20);
IntVec edges(20);
for (auto &el : edges)
el = RNG_INTEGER(0, graph.vcount());

Expand All @@ -31,4 +31,4 @@ int main() {
std::cout << "Average path length (randomized lattice): " << avg_path_len << std::endl;

return 0;
}
}
12 changes: 6 additions & 6 deletions examples/ex_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace ig;

// Support for printing vector lists.
template<typename T>
std::ostream & operator << (std::ostream &out, const igVecList<T> &list) {
std::ostream & operator << (std::ostream &out, const VecList<T> &list) {
for (const auto &vec : list)
std::cout << '(' << vec << ')' << std::endl;
return out;
Expand All @@ -23,11 +23,11 @@ int main() {

igraph_t ig;
igraph_erdos_renyi_game_gnp(&ig, 10, 0.5, IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS);
igGraph g(igCapture(ig));
Graph g(Capture(ig));

// igIntVecList is a wrapper for igraph_vector_int_list.
// It is a convenience alias to igIntVec<igraph_integer_t>.
igIntVecList list;
// IntVecList is a wrapper for igraph_vector_int_list.
// It is a convenience alias to IntVec<igraph_integer_t>.
IntVecList list;

// Compute maximal cliques and write the result into 'list'.
igraph_maximal_cliques(g, list, -1, -1);
Expand All @@ -45,7 +45,7 @@ int main() {
assert(list.back().empty());

// Add another element.
list.push_back(igIntVec{1,2,3});
list.push_back(IntVec{1,2,3});

// Reverse the list.
std::reverse(list.begin(), list.end());
Expand Down
2 changes: 1 addition & 1 deletion examples/ex_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace ig;
int main() {

// Create a matrix using a list initializer.
igRealMat mat = {{1, 2, 3},
RealMat mat = {{1, 2, 3},
{4, 5, 6}};

// Print the matrix using igraph features.
Expand Down
4 changes: 2 additions & 2 deletions examples/ex_vector_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

using namespace ig;

// Helper function to print igVec objects. Since igVec is templated, it is easy
// Helper function to print Vec objects. Since Vec is templated, it is easy
// to use a single definition for all of its specializations.
template<typename T>
std::ostream & operator << (std::ostream &out, const igVec<T> &v) {
std::ostream & operator << (std::ostream &out, const Vec<T> &v) {
for (auto it = v.begin(); it < v.end() - 1; ++it) {
out << *it << ' ';
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ex_views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {
// Here 'vec1' takes over the ownership of 'ig_vec1', and will free the underlying
// storage when 'vec1' goes out of scope. From this point on, 'ig_vec1' should not
// be used anymore.
igRealVec vec1(igCapture(ig_vec1));
RealVec vec1(Capture(ig_vec1));
std::cout << vec1 << std::endl;

igraph_real_t values[] = {1.2, 2.3, 3.4};
Expand All @@ -23,7 +23,7 @@ int main() {
// underlying storage. This is necessary in some cases, such as when a vector is a
// view into some existing buffer. If 'ig_vec2' ceases to exist, 'vec2' will no longer
// be valid.
const igRealVec vec2(igAlias(ig_vec2));
const RealVec vec2(Alias(ig_vec2));
std::cout << vec2 << std::endl;

return 0;
Expand Down
6 changes: 3 additions & 3 deletions include/graph_list_pmt.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#define GRAPH_LIST
#define LIST_TYPE igGraphList
#define LIST_TYPE_TEMPL igGraphList
#define ELEM_TYPE igGraph
#define LIST_TYPE GraphList
#define LIST_TYPE_TEMPL GraphList
#define ELEM_TYPE Graph
#include "typed_list_pmt.hpp"
#undef ELEM_TYPE
#undef LIST_TYPE_TEMPL
Expand Down
Loading

0 comments on commit 6687228

Please sign in to comment.