Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions D3126_Overview/tex/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ @online{REF_nwgraph_library
keywords = "graph,network,library"
}

@online{REF_stdgraph_library,
author = "Andrew Lumsdaine and Kevin Deweese and Scott McMillan and Phil Ratzloff",
title = "Standard graph library reference implementation, Version 2",
howpublished = {\url{"https://github.com/stdgraph/graph-v2"}},
addendum = "(accessed: 03.31.2025)",
keywords = "graph,network,library"
}

@online{REF_nwgraph_paper,
author = "Andrew Lumsdaine and Luke D'Alessandro and Kevin Deweese and Jesun Firoz and Tony Liu and Scott McMillan and Phil Ratzloff and Marcin Zalewski",
title = "NWGraph: A Library of Generic Graph Algorithms and Data Structures in C++20",
Expand All @@ -95,6 +103,13 @@ @INPROCEEDINGS{gapbs_2023
pages={216-227},
doi={10.1109/IISWC50251.2020.00029}}

@article{beamer2015gap,
title={The GAP benchmark suite},
author={Beamer, Scott and Asanovi{\'c}, Krste and Patterson, David},
journal={arXiv preprint arXiv:1508.03619},
year={2015}
}

@book{kepner-gilbert,
added-at = {2019-07-02T00:00:00.000+0200},
biburl = {https://www.bibsonomy.org/bibtex/2c2ffafc2f8a2dc9fad3539e6a5ff42d9/dblp},
Expand Down
Binary file modified D3337_Comparison.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions D3337_Comparison.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
\begin{document}
\maketitle


\clearpage

\input{tex/getting_started}
Expand Down
19 changes: 11 additions & 8 deletions D3337_Comparison/src/bgl_bfs.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using namespace std;
using namespace boost;

using G =
compressed_sparse_row_graph<directedS, no_property, no_property>;
using VId = graph_traits<G>::vertex_descriptor;
using G = compressed_sparse_row_graph<
directedS, no_property, no_property>;
using Vertex = graph_traits<G>::vertex_descriptor;

G g;
//populate g

vector<VId> parents(num_vertices(g));
vector<Vertex> parents(num_vertices(g));

auto vis = make_bfs_visitor(
make_pair(record_predecessors(parents.begin(), on_tree_edge())));


breadth_first_search(g, vertex(0, g), visitor(vis));
make_pair(
record_predecessors(parents.begin(),
on_tree_edge())));
breadth_first_search(g,
vertex(0, g),
visitor(vis));
7 changes: 4 additions & 3 deletions D3337_Comparison/src/bgl_cc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ using namespace std;
using namespace boost;

using G =
compressed_sparse_row_graph<directedS, no_property, no_property>;
compressed_sparse_row_graph<
directedS, no_property, no_property>;

G g;
//populate g

vector<size_t> c(N); //components
size_t num = connected_components(g, &c[0]);
vector<size_t> c(num_vertices(g)); //components
int num_cmps = connected_components(g, &c[0]);
22 changes: 16 additions & 6 deletions D3337_Comparison/src/bgl_sssp.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
using namespace std;
using namespace boost;

using G =
compressed_sparse_row_graph<directedS, no_property, property<edge_weight_t, int>>;
using VId = graph_traits<G>::vertex_descriptor;
using G = compressed_sparse_row_graph<
directedS, no_property,
property<edge_weight_t, int>>;
using Vertex = graph_traits<G>::vertex_descriptor;

G g;
//populate g

vector<VId> p(num_vertices(g)); //predecessors
vector<Vertex> p(num_vertices(g)); //predecessors
vector<int> d(num_vertices(g)); //distances

property_map< graph_t, edge_weight_t >::type weightmap = get(edge_weight, g);

property_map< graph_t, edge_weight_t >::type
weightmap = get(edge_weight, g);

dijkstra_shortest_paths(g, vertex(0, g), predecessor_map(make_iterator_property_map( p.begin(), get(vertex_index, g))).distance_map(make_iterator_property_map(d.begin(), get(vertex_index, g))));


dijkstra_shortest_paths(
g, vertex(0, g),
predecessor_map(
make_iterator_property_map(
p.begin(), get(vertex_index, g))).
distance_map(
make_iterator_property_map(
d.begin(), get(vertex_index, g))));
9 changes: 5 additions & 4 deletions D3337_Comparison/src/bgl_tc.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using namespace boost;

using G =
compressed_sparse_row_graph<directedS, no_property, no_property>;
using VId = graph_traits<G>::vertex_descriptor;
compressed_sparse_row_graph<
directedS, no_property, no_property>;
using Vertex = graph_traits<G>::vertex_descriptor;

G g;
//populate g

size_t count = 0;
size_t count{0};
for(size_t i = 0; i < N; i++) {
VId cur = vertex(i, g);
Vertex cur = vertex(i, g);
count += num_triangles_on_vertex(g, cur);
}
count /= 6;
44 changes: 44 additions & 0 deletions D3337_Comparison/src/bgl_tc_low.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using namespace boost;

using G =
compressed_sparse_row_graph<
directedS, no_property, no_property>;

using edge_iterator = graph_traits<G>::out_edge_iterator;

size_t N(num_vertices(g));
size_t triangles(0);

for (size_t uid = 0; uid < N; ++uid) {
Vertex u = vertex(uid, g);
std::pair<edge_iterator, edge_iterator>
u_neighbors = out_edges(u, g);

auto i = u_neighbors.first;
auto ie = u_neighbors.second;
while (i < ie) {
size_t vid = target(*i, g);
Vertex v = vertex(vid, g);
std::pair<edge_iterator, edge_iterator>
v_neighbors = out_edges(v, g);

auto i2 = i;
auto j = v_neighbors.first;
auto je = v_neighbors.second;

while (i2 < ie && j < je) {
size_t wid1 = target(*i2, g);
size_t wid2 = target(*j, g);
if (wid1 < wid2) {
++i2;
} else if (wid2 < wid1) {
++j;
} else {
++triangles;
++i2;
++j;
}
}
++i;
}
}
9 changes: 6 additions & 3 deletions D3337_Comparison/src/stdgraph_bfs.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
using namespace std;
using namespace graph;

using G = container::compressed_graph<void, void, void, uint32_t, uint32_t>;
using G = container::compressed_graph<
void, void, void, uint32_t, uint32_t>;
using VId = vertex_id_t<G>;

G g;
// populate g

vector<VId> parents(size(vertices(g));

auto bfs = edges_breadth_first_search_view<G,void,true>(g, 0);

auto bfs =
edges_breadth_first_search_view<G,void,true>(
g, 0);

for (auto&& [uid, vid, uv] : bfs) {
parents[vid] = uid;
}

7 changes: 4 additions & 3 deletions D3337_Comparison/src/stdgraph_cc.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using namespace std;
using namespace graph;

using G = container::compressed_graph<void, void, void, uint32_t, uint32_t>;

using G =
container::compressed_graph<
void, void, void, uint32_t, uint32_t>;

G g;
//populate g

vector<size_t> c(size(vertices(g))); //components
size_t num = connected_components(g, c);
int num_cmps = connected_components(g, c);



Expand Down
19 changes: 13 additions & 6 deletions D3337_Comparison/src/stdgraph_sssp.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using namespace std;
using namespace graph;

using G = container::compressed_graph<int, void, void, uint32_t, uint32_t>;

using G = container::compressed_graph<
int, void, void, uint32_t, uint32_t>;

using VId = vertex_id_t<G>;

G g;
Expand All @@ -11,11 +12,17 @@ G g;
vector<VId> p(size(vertices(g))); //predecessors
vector<int> d(size(vertices(g))); //distances
init_shortest_paths(distance, predecessors);
auto weight_fn = [&g](graph::edge_reference_t<graph_type> uv) -> int {
return edge_value(g, uv);
};

auto weight_fn =
[&g](graph::edge_reference_t<graph_type> uv)
-> int {
return edge_value(g, uv);
};







dijkstra_shortest_paths(g, 0, d, p, weight_fn);
dijkstra_shortest_paths(g, 0, d, p, weight_fn);
9 changes: 5 additions & 4 deletions D3337_Comparison/src/stdgraph_tc.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using namespace graph;

using G = container::compressed_graph<void, void, void, uint32_t, uint32_t>;

using G =
container::compressed_graph<
void, void, void, uint32_t, uint32_t>;


G g;
//populate g

size_t count;




count = triangle_count(g);

size_t count = triangle_count(g);



Expand Down
45 changes: 45 additions & 0 deletions D3337_Comparison/src/stdgraph_tc_low.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using namespace graph;

using G =
container::compressed_graph<
void, void, void, uint32_t, uint32_t>;




size_t N(size(vertices(g)));
size_t triangles(0);

for (vertex_id_t<G> uid = 0; uid < N; ++uid) {




incidence_iterator<G> i(g, uid);
auto ie = end(edges(g, uid));
while (i != ie) {
auto&& [vid, uv] = *i;




incidence_iterator<G> j(g, vid);
auto i2 = i;
auto je = end(edges(g, vid));

while (i2 != ie && j != je) {
auto&& [wid1, uw] = *i2;
auto&& [wid2, vw] = *j;
if (wid1 < wid2) {
++i2;
} else if (wid2 < wid1) {
++j;
} else {
++triangles;
++i2;
++j;
}
}
++i;
}
}
Loading
Loading