Use of SharePoint lists SQL

Oracle SQL and PL / SQL

Edsger W. Dijkstra's algorithm is used to determine the shortest paths from a start node to all other nodes in a graph.

The graph is displayed in the form of a simple table with the columns,, and.

The following graph serves as an example:

The associated table is then as follows:
ID SOURCE DESTINATION DISTANCE ---------- ---------- ----------- -------- 1 1 2 4 1 1 3 6 1 1 4 8 1 2 5 7 1 2 3 1 1 3 4 2 1 3 5 5 1 3 6 4 1 4 6 5 1 5 7 6 1 6 5 1 1 6 7 8 On this basis, the shortest routes should now be used can be found by node 1, although any node can be started.

The call of the PL / SQL table function goes like this:
select * from table (dijkstra (1,1)) order by vertex; VERTEX DISTANCE PREDECESSOR PATH ---------- -------- ----------- ----------------- ------ 1 0 1 2 4 1 1 -> 2 3 5 2 1 -> 2 -> 3 4 7 3 1 -> 2 -> 3 -> 4 5 10 3 1 -> 2 -> 3 - > 5 6 9 3 1 -> 2 -> 3 -> 6 7 16 5 1 -> 2 -> 3 -> 5 -> 7 The column indicates the minimum distance to the respective node, the column contains the direct predecessor and the Column contains the nodes which were covered by the shortest route.

After this brief demonstration of how it works, here is the associated code:
vertex): = zero; v_predecessor (init_rec.vertex): = null; v_distance (init_rec.vertex): = binary_double_infinity; end loop; v_distance (p_vertex_in): = 0; end; begin while (v_unchecked.count> 0) loop v_minimum: = null; i: = v_unchecked.first; while (i is not null) loop if (v_minimum is null) then v_minimum: = i; else if (v_distance (i) < v_distance(v_minimum))="" then="" v_minimum="" :="i;" end="" if;="" end="" if;="" i="" :="v_unchecked.next(i);" end="" loop;="" v_unchecked.delete(v_minimum);="" for="" distance_rec="" in="" distance_cur(v_minimum)="" loop="" if="" (v_unchecked.exists(distance_rec.destination))="" then="" v_alternative="" :="v_distance(v_minimum)" +="" distance_rec.distance;="" if="" (v_alternative="">< v_distance(distance_rec.destination))="" then="" v_distance(distance_rec.destination)="" :="v_alternative;" v_predecessor(distance_rec.destination)="" :="v_minimum;" end="" if;="" end="" if;="" end="" loop;="" if="" (v_distance(v_minimum)="binary_double_infinity)" then="" v_path="" :='' ;="" else="" v_path="" :="v_minimum;" end="" if;="" i="" :="v_predecessor(v_minimum);" while="" (i="" is="" not="" null)="" loop="" v_path="" :="i" ||="" '="" -=""> '|| v_path; i: = v_predecessor (i); end loop; pipe row (dijkstra_t (v_minimum, v_distance (v_minimum), v_predecessor (v_minimum), v_path)); end loop; end; exception when graph_not_found then raise_application_error (-20010, 'DIJKSTRA: The graph was not found.'); when vertex_not_found then raise_application_error (-20011, 'DIJKSTRA: The vertex to start the algorithm was not found.'); when others then raise_application_error (-20012, 'DIJKSTRA: Unexpected error:' || substr (1,200, SQLERRM)); end;