Skip to content

Commit

Permalink
:octocat: Applied clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
pratzl authored and github-actions[bot] committed Dec 15, 2024
1 parent d0470dd commit fb61ed3
Show file tree
Hide file tree
Showing 3 changed files with 5,824 additions and 6,370 deletions.
132 changes: 65 additions & 67 deletions example/CppCon2021/examples/graphs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,35 @@ int main() {
std::cout << "Karate adjacency list:\n";
std::cout << "size = " << G.size() << std::endl;
for (size_t uid = 0; uid < G.size(); ++uid) {
std::cout << std::setw(3) << uid << ":";
for (auto&& vid : G[uid]) {
std::cout << " " << vid;
}
std::cout << std::endl;
std::cout << std::setw(3) << uid << ":";
for (auto&& vid : G[uid]) {
std::cout << " " << vid;
}
std::cout << std::endl;
}

std::vector<std::list<std::tuple<size_t>>> H(34);
push_back_plain_fill(karate_index_edge_list, H, false, 0);
std::cout << "\nKarate (edge_list plain fill):\n";
std::cout << "size = " << H.size() << std::endl;
for (size_t uid = 0; uid < H.size(); ++uid) {
std::cout << std::setw(3) << uid << ":";
for (auto&& [vid] : H[uid]) {
std::cout << " " << vid;
}
std::cout << std::endl;
std::cout << std::setw(3) << uid << ":";
for (auto&& [vid] : H[uid]) {
std::cout << " " << vid;
}
std::cout << std::endl;
}


push_back_fill(karate_index_edge_list, H, false, 0);
std::cout << "\nKarate (edge_list fill...adding more):\n";
std::cout << "size = " << H.size() << std::endl;
for (size_t uid = 0; uid < H.size(); ++uid) {
std::cout << std::setw(3) << uid << ":";
for (auto&& [vid] : H[uid]) {
std::cout << " " << vid;
}
std::cout << std::endl;
std::cout << std::setw(3) << uid << ":";
for (auto&& [vid] : H[uid]) {
std::cout << " " << vid;
}
std::cout << std::endl;
}

//----------------------------------------------------------------------------
Expand All @@ -83,57 +83,57 @@ int main() {
std::cout << "\nOSPF plain graph:\n";
std::cout << "size = " << a.size() << std::endl;
for (size_t uid = 0; uid < a.size(); ++uid) {
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& vid : a[uid]) {
std::cout << " " << ospf_vertices[vid];
}
std::cout << std::endl;
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& vid : a[uid]) {
std::cout << " " << ospf_vertices[vid];
}
std::cout << std::endl;
}

auto b = make_property_graph(ospf_vertices, ospf_edges);
std::cout << "\nOSPF property graph:\n";
std::cout << "size = " << b.size() << std::endl;
for (size_t uid = 0; uid < b.size(); ++uid) {
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& [vid, val] : b[uid]) {
std::cout << " " << ospf_vertices[vid] << ":" << val;
}
std::cout << std::endl;
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& [vid, val] : b[uid]) {
std::cout << " " << ospf_vertices[vid] << ":" << val;
}
std::cout << std::endl;
}

auto c = make_index_graph(ospf_vertices, ospf_edges);
std::cout << "\nOSPF index graph:\n";
std::cout << "size = " << c.size() << std::endl;
for (size_t uid = 0; uid < c.size(); ++uid) {
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& [vid, val] : c[uid]) {
std::cout << " " << ospf_vertices[vid] << ":" << std::get<2>(ospf_edges[val]);
}
std::cout << std::endl;
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& [vid, val] : c[uid]) {
std::cout << " " << ospf_vertices[vid] << ":" << std::get<2>(ospf_edges[val]);
}
std::cout << std::endl;
}

auto d = make_plain_graph<decltype(ospf_vertices), decltype(ospf_edges), std::vector<std::list<size_t>>>(
ospf_vertices, ospf_edges, true);
std::cout << "\nOSPF plain graph (vector of lists):\n";
std::cout << "size = " << d.size() << std::endl;
for (size_t uid = 0; uid < d.size(); ++uid) {
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& vid : d[uid]) {
std::cout << " " << ospf_vertices[vid];
}
std::cout << std::endl;
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& vid : d[uid]) {
std::cout << " " << ospf_vertices[vid];
}
std::cout << std::endl;
}

auto e = make_index_graph<decltype(ospf_vertices), decltype(ospf_edges),
std::vector<std::vector<std::tuple<size_t, size_t>>>>(ospf_vertices, ospf_edges, true);
std::cout << "\nOSPF index graph (vector of vector of tuples):\n";
std::cout << "size = " << e.size() << std::endl;
for (size_t uid = 0; uid < e.size(); ++uid) {
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& [vid, val] : e[uid]) {
std::cout << " " << ospf_vertices[vid] << ":" << std::get<2>(ospf_edges[val]);
}
std::cout << std::endl;
std::cout << std::setw(3) << ospf_vertices[uid] << ":";
for (auto&& [vid, val] : e[uid]) {
std::cout << " " << ospf_vertices[vid] << ":" << std::get<2>(ospf_edges[val]);
}
std::cout << std::endl;
}

//----------------------------------------------------------------------------
Expand All @@ -144,19 +144,19 @@ int main() {
std::cout << "\nMovies-actors plain bipartite graphs\n";
std::cout << "index 0: " << f.size() << "==" << h.size() << std::endl;
for (size_t uid = 0; uid < f.size(); ++uid) {
std::cout << std::setw(20) << movies[uid] << ": |";
for (auto&& vid : f[uid]) {
std::cout << actors[vid] << "|";
}
std::cout << std::endl;
std::cout << std::setw(20) << movies[uid] << ": |";
for (auto&& vid : f[uid]) {
std::cout << actors[vid] << "|";
}
std::cout << std::endl;
}
std::cout << "index 1: " << g.size() << "==" << i.size() << std::endl;
for (size_t uid = 0; uid < g.size(); ++uid) {
std::cout << std::setw(20) << actors[uid] << ": |";
for (auto&& vid : g[uid]) {
std::cout << movies[vid] << "|";
}
std::cout << std::endl;
std::cout << std::setw(20) << actors[uid] << ": |";
for (auto&& vid : g[uid]) {
std::cout << movies[vid] << "|";
}
std::cout << std::endl;
}

auto [j, k] = make_plain_bipartite_graphs<decltype(movies), decltype(actors), decltype(movies_actors),
Expand All @@ -168,19 +168,19 @@ int main() {
std::cout << "\nMovies-actors plain bipartite graphs (vector of lists)\n";
std::cout << "index 0: " << j.size() << "==" << l.size() << std::endl;
for (size_t uid = 0; uid < j.size(); ++uid) {
std::cout << std::setw(20) << movies[uid] << ": |";
for (auto&& vid : j[uid]) {
std::cout << actors[vid] << "|";
}
std::cout << std::endl;
std::cout << std::setw(20) << movies[uid] << ": |";
for (auto&& vid : j[uid]) {
std::cout << actors[vid] << "|";
}
std::cout << std::endl;
}
std::cout << "index 1: " << k.size() << "==" << m.size() << std::endl;
for (size_t uid = 0; uid < k.size(); ++uid) {
std::cout << std::setw(20) << actors[uid] << ": |";
for (auto&& vid : k[uid]) {
std::cout << movies[vid] << "|";
}
std::cout << std::endl;
std::cout << std::setw(20) << actors[uid] << ": |";
for (auto&& vid : k[uid]) {
std::cout << movies[vid] << "|";
}
std::cout << std::endl;
}

//----------------------------------------------------------------------------
Expand All @@ -197,16 +197,14 @@ int main() {
std::cout << "\nSpice property graph (using edges+values)\n";
std::cout << "Size: " << s.size() << std::endl;
for (size_t uid = 0; uid < s.size(); ++uid) {
std::cout << std::setw(4) << spice_vertices[uid] << ": |";
for (auto&& [vid, comp, val] : s[uid]) {
std::cout << std::setw(3) << spice_vertices[vid] << ":" << comp << "/" << val << "|";
}
std::cout << std::endl;
std::cout << std::setw(4) << spice_vertices[uid] << ": |";
for (auto&& [vid, comp, val] : s[uid]) {
std::cout << std::setw(3) << spice_vertices[vid] << ":" << comp << "/" << val << "|";
}
std::cout << std::endl;
}




//bfs_edge_range(n, 1);
graph::views::edges_breadth_first_search(n, 1);

Expand Down
8 changes: 5 additions & 3 deletions example/CppCon2021/examples/ospf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ int main() {

bool pass = true;
for (size_t i = 0; i < size(ospf_vertices); ++i) {
std::cout << std::setw(6) << ospf_vertices[i] << std::setw(6) << e[i] << std::endl;
if (e[i] != d[i]) pass = false;
std::cout << std::setw(6) << ospf_vertices[i] << std::setw(6) << e[i] << std::endl;
if (e[i] != d[i])
pass = false;
}
std::cout << (pass ? "***PASS***" : "***FAIL***") << std::endl;

Expand All @@ -73,7 +74,8 @@ int main() {
bool pass2 = true;
for (size_t i = 0; i < size(ospf_vertices); ++i) {
std::cout << std::setw(6) << ospf_vertices[i] << std::setw(6) << e[i] << std::endl;
if (e[i] != d[i]) pass2 = false;
if (e[i] != d[i])
pass2 = false;
}
std::cout << (pass2 ? "***PASS***" : "***FAIL***") << std::endl;

Expand Down
Loading

0 comments on commit fb61ed3

Please sign in to comment.