I'm trying to make a matrix that shows the cost from a node to the rest of the nodes in a network.

The final result I'm looking for is not the cost, but only know if a car can or can not reach each vertex.

I've made a test in a small area of my network, and it seems to work perfectly. I get the cost from a node to the rest, and if can't reach it, only leaves the value as NULL, then I can set this value to false.

The problem is where I try to extend this methodology to the rest of the network, I get an error showing that the target vertex was not found.

Why is pgRouting saying this, if I'm doing the same analysis?

The steps I've followed are:

--creating topology
ALTER TABLE "3prueba" ADD COLUMN "source" integer;
ALTER TABLE "3prueba" ADD COLUMN "target" integer;
SELECT pgr_createTopology('3prueba', 0.00001, 'geom', 'id');
--(I already have the cost field)
CREATE INDEX vials3_source_indx ON calles("source");
CREATE INDEX vials3_target_indx ON calles("target");
create table "3catchment82" as 
    (select sum(cost) from (
       SELECT * FROM pgr_dijkstra('
       SELECT id AS id,
          source::int4 AS source,
          target::int4 AS target,
          coste::float8 AS cost
       FROM "3prueba" where mostrar = 1 
       ', --<-- show only roads
       82, --<-- specify node
       false)) as foo ) as cost
from "3prueba_vertices_pgr"

This are the steps I've followed.

The main idea is get the costs only for the roads with the field "mostrar=1", as I show in the image. If the road is closed (mostrar=0) it can not reach the node. So, the red road is closed, and can not reach nodes 58, 59, 5... After this,I'll change the roads. So, I can get a matrix when some roads are closed, other matrix when other roads are closed, etc. enter image description here When I apply this analysis to the rest of the network, I get the error.

Any Idea of what am I doing wrong, or what would be the correct way to do this?

After @underdark advice, it seems to work.

I've run the model applying a high cost to the 'closed' roads, and seems to be ok.

I've seen that there are 3 types of output:

  • In green: nodes that the source reaches.

  • In red: nodes that source do not reach.

  • In orange: nodes disconnected. The values was NULL.

So, I think the problem was with this type of nodes. enter image description here

1 Answer 1


I assume it's running into trouble when you try to route from one part on the network to another part which is disconnected due to closure (e.g. when link 58-47 is removed). Instead of removing these links, try to put their costs really high. That way, you will be able to identify those links which get disconnected by their high cost sums.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.