Skip to content

Instantly share code, notes, and snippets.

View Zia-'s full-sized avatar
๐Ÿ™
I might be slow in response.

Mohammed Zia Zia-

๐Ÿ™
I might be slow in response.
View GitHub Profile
@Zia-
Zia- / Boost_Reference_Manual_Page_169_code.cpp
Last active September 16, 2015 15:02
Modified form of "example/bfs-example.cpp" code (https://github.com/boostorg/graph/blob/master/example/bfs-example.cpp) showing BFS with visitors
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <boost/range/irange.hpp>
#include <iostream>
template < typename TimeMap > class bfs_time_visitor:public boost::default_bfs_visitor {
typedef typename boost::property_traits < TimeMap >::value_type T;
public:
#include <boost/graph/adjacency_list.hpp>
template <typename DirectedGraph>
void directed_graph_demo(){
/*The value of V is not imp, we need it just to pass into constructor at "UndirectedGraph undigraph(V);" to initialize it.
Later on we can add as many vertices as we want*/
const int V = 0;
DirectedGraph digraph(V);
typename boost::graph_traits<DirectedGraph>::vertex_descriptor u, v;
//edge_property_type Weight will be used to pass weight values for each edge
#include <boost/graph/adjacency_list.hpp>
template <typename UndirectedGraph>
void undirected_graph_demo1(){
/*The value of V is not imp, we need it just to pass into constructor at "UndirectedGraph undigraph(V);" to initialize it.
Later on we can add as many vertices as we want*/
const int V = 0;
UndirectedGraph undigraph(V);
typename boost::graph_traits<UndirectedGraph>::vertex_descriptor zero, one, two;
typename boost::graph_traits<UndirectedGraph>::out_edge_iterator out, out_end;
#include <fstream>
#include <boost/graph/adjacency_list.hpp>
//The obj of this struct will hold the import file data
typedef struct {
int64_t id;
int64_t source;
int64_t target;
} pgr_edge_t;
#include <boost/config.hpp>
#include <iostream>
#include "postgres.h"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/astar_search.hpp>
@Zia-
Zia- / graphBoostTest1.cpp
Last active August 29, 2015 14:27
Trying to replicate the test done by Vicky to see how to use an external file as graph data provider (https://gist.github.com/cvvergara/1e31d1ad14db171b26d4#file-graphboosttest1-cpp-L5)
#include <boost/config.hpp>
#include <iostream>
#include <stdlib.h>
#include <fstream>
//To include the lib file from a local dir: http://stackoverflow.com/questions/15935207/adding-header-files-to-eclipse-build-path-for-c
#include "postgres.h"
#include <boost/graph/adjacency_list.hpp>
/*