<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
span.gmail-pre
        {mso-style-name:gmail-pre;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:11.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#467886" vlink="#96607D" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>pgr_dijstra just takes an SQL query. The only distinction about the SQL vs. other SQL you might write is that id, source, target, cost are columns. You can add more columns and extra columns will be ignored and can use any WHERE clause you like. You can even use fancy things like CTEs and functions<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>For example:<o:p></o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>SELECT * FROM pgr_Dijkstra(<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>  $sql$SELECT id, source, target, cost, reverse_cost FROM edges<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>WHERE subgraph = 'train' $sql$,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>  6, ARRAY[10, 17]);<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I also like using PostgreSQL dollar quoting if my where clause has strings. That way you don’t have to escape for example ‘train’.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The above could also be written without dollar quoting as follows:<o:p></o:p></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>SELECT * FROM pgr_Dijkstra(<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>  'SELECT id, source, target, cost, reverse_cost FROM edges<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>WHERE subgraph = ''train'' ',<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>  6, ARRAY[10, 17]);<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Pgrouting-users <pgrouting-users-bounces@lists.osgeo.org> <b>On Behalf Of </b>Hugh Kelley via Pgrouting-users<br><b>Sent:</b> Thursday, June 6, 2024 11:37 AM<br><b>To:</b> pgRouting users mailing list <pgrouting-users@lists.osgeo.org><br><b>Subject:</b> [pgrouting-users] compare routes between full network and subset<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Hi,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I am looking to compare the directness of routes between the entirety of a network and a subset of the same network. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I see in pgr_createTopology that there is a <span class=gmail-pre><span style='font-size:10.0pt;font-family:"Courier New"'>rows_where</span></span> argument to filter the network. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>When I use pgr_dijkstra to calculate routes between node pairs, if I've created two separate topologies, one with the full network and another with the subset using "rows_where". Can i somehow specify which topology the dijkstra algorithm should use? <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It occurred to me that I could just include a where clause in the "edges sql" that I provide pgr_dijkstra but I can't find an example of that being done anywhere. <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>In previous work I've simply made two tables, network and network_subset and then just created topologies for each and calculated routes for each network separately but it seems like I'm just not seeing exactly how to do the same thing in a simpler manner with the "rows_where" argument or some other option.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks for any solutions or suggestions!<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Hugh  <o:p></o:p></p></div><div><div><div><div><div><div><div><div><div><p class=MsoNormal><o:p> </o:p></p></div></div></div></div></div></div></div></div></div></div></div></div></body></html>