Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

C/C++ • Re: Boost provides free peer-reviewed portable C++ source libraries.

$
0
0
Since I am interested in even bigger graphs I just booted an old Xeon e5-2680 (2CPU) 24C/48T — that has 384GB of ram and should get me further ...
I had to increase number datatype from 32 bit (int) to 64bit (long).
On that machine RAM size is no issue at all.
I played with different bigger graphs, the last had these numbers:
  • it took 6:26min to compute 9,410,70 vertices
  • it took 43:59min to add all needed edges
  • it took (only) 8.44825s to determine BFS distance from single source to all other vertices and overall maximal distance
I used "top" to determine pid (5335), and then did:

Code:

$ while true; do grep ^Vm[PH][eW] /proc/5335/status ; sleep 1; done | tee out
This gave complete view of virtual and resident process RAM usage:

Code:

$ head -4  out && echo "..." && tail -2 out VmPeak:   44836 kBVmHWM:   12284 kBVmPeak:   44836 kBVmHWM:   12284 kB...VmPeak:161093068 kBVmHWM:142040812 kB$
More than 142GB RAM resident memory, nice.

This completes my evaluations of the graphs I am interested in; and seems to confirm that path of length <=3 exists from all vertices to single source.



Next BGL topic.
I did write my own LEDA graph reader in straight_line_graphviz.cpp discussed above.
There is a BGL function "read_graphviz()" that allows to read a graphviz .dot file into BGL graph representation.
It has its limits, so I created only small dot2leda.cpp gist allowing to convert simple .dot files into LEDA format:
https://gist.github.com/Hermann-SW/fc6c ... 5a38a9a30a

What is special is that for this code to compile you have to link against boost_graph lib (most Boost stuff is header only):

Code:

$ f=dot2leda$ g++ -O3 -Wall -pedantic -Wextra $f.cpp -o $f -lboost_graph$ cpplint --filter=-legal/copyright,-build/namespaces $f.cppDone processing dot2leda.cpp$ cppcheck --enable=all --suppress=missingIncludeSystem $f.cpp --check-configChecking dot2leda.cpp ...$ 
All details in the comments of dot2leda.cpp gist.
You can nest all tools discussed sofar:

Code:

$ GraphvizFiddle.py chromium-browser <(../straight_line_graphviz <(./dot2leda <(curl -s https://stamm-wilbrandt.de/C60.dot)))$ 
After adding size="10,200" at bottom and clicking "Draw" button you get this planar straight line drawing in browser:
BGL.C60.planar_straight_line_drawing.jpg

It reads (with curl) C60 fullerene .dot file from my personal website, converts to LEDA format, generates planar straight line drawing and displays in browser. The bold edges belong to C60, the dotted edges were added to create maximal planar graph in between.

This graph has twenty 6-gons and twelve 5-gons, you are likely to know that graph — C60 is also called "football fullerene":
Image


What I really like about dot2leda.cpp gist is, how short the read+convert part is.
In the gist it takes 20 lines nicely formatted:
https://gist.github.com/Hermann-SW/fc6c ... pp-L31-L50

I stuffed those lines together to make a single 11line comment here:

Code:

    ifstream gvgraph(argv[1]);    assert(read_graphviz(gvgraph, graph, dp, "node_id"));    cout << "LEDA.GRAPH" << "\nstring" << "\nint" << "\n";    cout << num_vertices(graph) << "\n";    BOOST_FOREACH(graph_t::vertex_descriptor v, vertices(graph)) {        cout << get("node_id", dp, v) << "\n"; }    cout << num_edges(graph) << "\n";    BOOST_FOREACH(graph_t::edge_descriptor e, edges(graph)) {        cout << 1+source(e, graph) << " " << 1+target(e, graph)             << " " << 0 << "\n"; }

Statistics: Posted by HermannSW — Mon Mar 18, 2024 8:51 pm



Viewing all articles
Browse latest Browse all 8609

Trending Articles