contract_rt#L61 this tells you whether an edge or a vertex was contracted
if it is an edge then type = 'e'
if it is a vertex then type = 'v'
Query
SELECT * from pgr_contractGraph('SELECT id, source, target, cost, reverse_cost from edge_table WHERE id = 6 OR id = 7', ARRAY[1]);
Result sampledata=# SELECT * from pgr_contractGraph('SELECT id, source, target, cost, reverse_cost from edge_table WHERE id = 6 OR id = 7', ARRAY[1]); seq | type | id | contracted_vertices | source | target | cost -----+------+----+---------------------+--------+--------+------ 1 | v | 5 | {7,8} | -1 | -1 | -1
Observations:
If you look at the sample data, and consider only the edges with id = 6 and id = 7 the dead end contraction contracts vertices 7 and 8 to vertex 5
Q. why is the type in the output 'v' A. Because the resultant output is a vertex
Q. the source, target and cost all -1; why? A. Because there is no edge
The id is 5 because the vertices 7 and 8 were contracted to vertex 5
Q. What is contracted_vertices_size in the query we executed. A. 2
Q. What is contracted_vertices_array in the query we executed earlier. A. {7,8}
contractGraph.c#L205. What do you see? A. Here we are allocating memory to the contracted_vertices_array pointer
contractGraph.c#L201 we assign the size of the contract vertices size array to a variable. we get the size from the result_tuples
contractGraph.c#L208. Here we are populating the contracted_vertices_array with the values
How many columns did you see when we executed the previous query. 7. We can find that here contractGraph.c#L193. In the subsequent code we populate the values array contractGraph.c#L245
Each element in the values array is of type Datum so we need to convert the result which is composed of different types into Datum contractGraph.c#L247
What is the use of call_cntr contractGraph.c#L190. It is the value of the seq column we saw in the output before.
contractGraph.c#L184. The code in this if condition executes for every row that is returned. So the call_cntr signifies the number of rows returned by the query and the call_cntr starts with 0
contractGraph.c Code
Return type of contraction function contract_rt#L61
contract_rt#L61 this tells you whether an edge or a vertex was contracted
Query
SELECT * from pgr_contractGraph('SELECT id, source, target, cost, reverse_cost from edge_table WHERE id = 6 OR id = 7', ARRAY[1]);
Result
sampledata=# SELECT * from pgr_contractGraph('SELECT id, source, target, cost, reverse_cost from edge_table WHERE id = 6 OR id = 7', ARRAY[1]); seq | type | id | contracted_vertices | source | target | cost -----+------+----+---------------------+--------+--------+------ 1 | v | 5 | {7,8} | -1 | -1 | -1
Observations:
contractGraph.c#L205. What do you see? A. Here we are allocating memory to the contracted_vertices_array pointer
contractGraph.c#L201 we assign the size of the contract vertices size array to a variable. we get the size from the result_tuples
contractGraph.c#L208. Here we are populating the contracted_vertices_array with the values
contractGraph.c#L187. This is the values pointer and we allocate memory to the values pointer here contractGraph.c#L194
How many columns did you see when we executed the previous query. 7. We can find that here contractGraph.c#L193. In the subsequent code we populate the values array contractGraph.c#L245
Each element in the values array is of type Datum so we need to convert the result which is composed of different types into Datum contractGraph.c#L247
What is the use of call_cntr contractGraph.c#L190. It is the value of the seq column we saw in the output before.
contractGraph.c#L184. The code in this if condition executes for every row that is returned. So the call_cntr signifies the number of rows returned by the query and the call_cntr starts with 0