The analyses of one way segments is pretty simple but can be a powerful tools to identifying some the potential problems created by setting the direction of a segment the wrong way. A node is a source if it has edges the exit from that node and no edges enter that node. Conversely, a node is a sink if all edges enter the node but none exit that node. For a source type node it is logically impossible to exist because no vehicle can exit the node if no vehicle and enter the node. Likewise, if you had a sink node you would have an infinite number of vehicle piling up on this node because you can enter it but not leave it.

So why do we care if the are not feasible? Well if the direction of an edge was reversed by mistake we could generate exactly these conditions. Think about a divided highway and on the north bound lane one segment got entered wrong or maybe a sequence of multiple segments got entered wrong or maybe this happened on a round-about. The result would be potentially a source and/or a sink node.

So by counting the number of edges entering and exiting each node we can identify both source and sink nodes so that you can look at those areas of your network to make repairs and/or report the problem back to your data vendor.

Prerequisites

The edge table to be analyzed must contain a source column and a target column filled with id’s of the vertices of the segments and the corresponding vertices table <edge_table>_vertices_pgr that stores the vertices information.