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- / 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>
/*
#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>
#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/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 <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
@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:
@Zia-
Zia- / Boost_Reference_Manual_Page_173_code.cpp
Last active September 16, 2015 15:03
Modified form of "example/dfs-example.cpp" code (https://github.com/boostorg/graph/blob/master/example/dfs-example.cpp) showing DFS with visitors
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/range/irange.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <iostream>
template < typename TimeMap > class dfs_time_visitor:public boost::default_dfs_visitor {
typedef typename boost::property_traits < TimeMap >::value_type T;
public:
@Zia-
Zia- / Boost_Reference_Manual_Page_181_code.cpp
Created September 18, 2015 06:59
Modified form of "example/dijkstra-example.cpp" code (https://github.com/boostorg/graph/blob/master/example/dijkstra-example.cpp) showing Dijkstra with predecessor and distance maps.
#include <boost/config.hpp>
#include <iostream>
#include <fstream>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/property_map/property_map.hpp>
@Zia-
Zia- / osm_nodes_from_xml2json.py
Last active April 12, 2016 14:18
Convert OSM nodes XML data into JSON format
import csv
from xml.dom import minidom
from osgeo import ogr
import os, sys
abs_file_path = "<path_to_planet_osm_file>/planet.osm";
xmldoc = minidom.parse(abs_file_path)
json_list = list()
import math
from xml.dom import minidom
def coord(way_id):
abs_file_path = "/Users/zia/Documents/Test/osm_road_length_data/itu_maslak.osm";
xmldoc = minidom.parse(abs_file_path)
way = xmldoc.getElementsByTagName("way")
def node_coord(node_id):
node = xmldoc.getElementsByTagName("node")