Skip to content

Instantly share code, notes, and snippets.

@cvvergara
cvvergara / modified_pgr_analyzegraph
Last active December 21, 2015 03:59
pgr_analyzegraph considering schemas also modified pgr_iscolumnintable pgr_iscolumnindexed
/*
Modification of
pgr_iscolumnintable(tab text, col text)
pgr_iscolumnindexed(tab text, col text)
pgr_analyzegraph(edge_tab text, geom_col text, tol double precision)
that handles schemas
*/
CREATE OR REPLACE FUNCTION pgr_isColumnInTableV2(tab text, col text)
/*
@cvvergara
cvvergara / graphBoostTest.cpp
Created March 28, 2015 20:44
Documentation Data Using boost::Directed Graph, boost::Undirected Graph and Generating the Undirected graph in a boost::Directed graph
#include <boost/config.hpp>
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/iteration_macros.hpp>
/*
To be able to distinguish the edges (source,target) from the (target,source)
"cost" column weights are set to 1 for (source,target)
"reverse_cost" column weights are set to 2 for (target,source)
@cvvergara
cvvergara / graphBoostTest.expected
Created March 28, 2015 20:47
graphBoostTest results
UNDIRECTED GRAPH DEMO
out_edges(0):
out_edges(1): (1,2)=1 (1,2)=2
out_edges(2): (2,1)=1 (2,5)=1 (2,1)=2 (2,3)=2 (2,5)=2
out_edges(3): (3,6)=1 (3,2)=2 (3,4)=2
out_edges(4): (4,9)=1 (4,3)=2 (4,9)=2
out_edges(5): (5,2)=1 (5,8)=1 (5,6)=1 (5,10)=1 (5,2)=2 (5,8)=2 (5,6)=2 (5,10)=2
out_edges(6): (6,3)=1 (6,5)=1 (6,9)=1 (6,11)=1 (6,5)=2 (6,9)=2
out_edges(7): (7,8)=1 (7,8)=2
out_edges(8): (8,7)=1 (8,5)=1 (8,7)=2 (8,5)=2
@cvvergara
cvvergara / graphBoostTest1.cpp
Last active August 29, 2015 14:17
Stores in an array pgr edge structure and that serves as the input of the graphs (graphBoostTest.expected)
#include <boost/config.hpp>
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include "postgres.h"
#include <boost/graph/adjacency_list.hpp>
/*
To be able to distinguish the edges (source,target) from the (target,source)
@cvvergara
cvvergara / sampledata.data
Created March 29, 2015 23:40
Sample data from the documentation (except reverse_cost is 2)
18
1 1 2 1 2
2 2 3 -1 2
3 3 4 -1 2
4 2 5 1 2
5 3 6 1 -1
6 7 8 1 2
7 8 5 1 2
8 5 6 1 2
9 6 9 1 2
@cvvergara
cvvergara / graphBoostTest2.cpp
Created March 30, 2015 04:13
Based on pgr_edge_t the graph is loaded
#include <boost/config.hpp>
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include "postgres.h"
#include <boost/graph/adjacency_list.hpp>
/*
To be able to distinguish the edges (source,target) from the (target,source)
@cvvergara
cvvergara / boostDijkstraTest.expected
Created March 30, 2015 07:32
boostDijkstraTest results
UNDIRECTED GRAPH DEMO
out_edges(0):
out_edges(1): (1,2)=1 (1,2)=2
out_edges(2): (2,1)=1 (2,1)=2 (2,3)=2 (2,5)=1 (2,5)=2
out_edges(3): (3,2)=2 (3,4)=2 (3,6)=1
out_edges(4): (4,3)=2 (4,9)=1 (4,9)=2
out_edges(5): (5,2)=1 (5,2)=2 (5,8)=1 (5,8)=2 (5,6)=1 (5,6)=2 (5,10)=1 (5,10)=2
out_edges(6): (6,3)=1 (6,5)=1 (6,5)=2 (6,9)=1 (6,9)=2 (6,11)=1
out_edges(7): (7,8)=1 (7,8)=2
out_edges(8): (8,7)=1 (8,7)=2 (8,5)=1 (8,5)=2
@cvvergara
cvvergara / boostDijkstraTest1.cpp
Created March 30, 2015 17:42
Dijkstra in with woriking only on the directed graph code going from 2 to 3
#include <boost/config.hpp>
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include "postgres.h"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
/*
@cvvergara
cvvergara / boostDijkstraTest2.cpp
Created March 30, 2015 17:49
Dijkstra in with working only on the the 3 graphs graphs. And stopping when target is reached. Going from 2 to 3 and from 3 to 2
#include <boost/config.hpp>
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include "postgres.h"
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
/*
@cvvergara
cvvergara / sampledataSparce.data
Created April 9, 2015 05:10
Documentation Data, but vertices id's are times 10
18
1 10 20 1 2
2 20 30 -1 2
3 30 40 -1 2
4 20 50 1 2
5 30 60 1 -1
6 70 80 1 2
7 80 50 1 2
8 50 60 1 2
9 60 90 1 2