The node number in the digraph does not match the node number used in shortestpath().

2 views (last 30 days)
I created a digraph of a certain track and tried to find the shortest path using the shortestpath() function. But for some reason, Mattlab calculated the shortest path using the wrong starting point and target point. For example, in the following case, I wanted to find the shortest path from node 228 to 231, but it found the path from node 229 to 232 instead. What is the cause of this and how can I resolve it?
all_ids = {'1','2','3','4','5','6','7','8','9','10','11','12','18','17','16','15','13','14','19','20','21','27','26','25','24','22','23','28','29','30','36','35','34','33','31','32','37','38','39','45','44','43','42','40','41','46','47','48','54','53','52','51','49','50','55','56','57','63','62','61','60','58','59','64','65','66','72','71','70','69','67','68','73','74','75','81','80','79','78','76','77','82','83','84','85','86','87','89','90','91','92','93','94','95','96','97','98','99','100','101','102','103','104','105','106','107','108','109','110','111','112','113','114','115','116','117','118','119','120','121','122','123','124','125','126','127','128','129','130','131','132','133','134','135','136','137','138','139','140','141','142','143','144','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192','193','194','195','196','197','198','199','200','201','202','203','204','205','206','207','208','209','210','211','212','213','214','215','216','217','218','219','220','221','222','223','224','225','226','227','228','229','230','231','232','233','234','235','236','237','238','239','240','241','242','243','244','245','246','247','248','249','250','251','252','253','254','255','256','257','258','259','260','261','262','263','264','265','266','267','268','269','270','271','272','273','274','275','276','277','278','279','280','281','282','283','284','285','286','287','288','289','290','291','292','293','294','295','296','297','298','299','300','301','302','303','304','305','306','307','308','309','310','311','312','313','314','315','316','317','318','319','320','321','322','323','324','325','326','327','328','329','330','331','332','333','334','335','336','337','338','339','340','341','342','343','344','345','346','347','348','349','350','351','352','353','354','355','356','357','358','359','360','361','362','363','364','365','366','367','368','369','370','371','372','373','374','375','376','377','378','379','380','381','382','383','384','385','386','387','388','389','390','391','392','393','394','395','396','397','398','399','400','401','402','403','404','405','406','407','408','409','410','411','412','413','414','415','416','417','418','419','420','421','422','423','424','425','426','427','428','429','430','431','432','433','434','435','436','437','438','439','440','441','442','443','444','445','446','447','448','449','450','451','452','453','454','455','456','457','458','459','460','461','462','463','464','465','466','467','468'};
all_names = {'1','2','3','4','5','6','7','8','9','10','11','12','18','17','16','15','13','14','19','20','21','27','26','25','24','22','23','28','29','30','36','35','34','33','31','32','37','38','39','45','44','43','42','40','41','46','47','48','54','53','52','51','49','50','55','56','57','63','62','61','60','58','59','64','65','66','72','71','70','69','67','68','73','74','75','81','80','79','78','76','77','82','83','84','85','86','87','89','90','91','92','93','94','95','96','97','98','99','100','101','102','103','104','105','106','107','108','109','110','111','112','113','114','115','116','117','118','119','120','121','122','123','124','125','126','127','128','129','130','131','132','133','134','135','136','137','138','139','140','141','142','143','144','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192','193','194','195','196','197','198','199','200','201','202','203','204','205','206','207','208','209','210','211','212','213','214','215','216','217','218','219','220','221','222','223','224','225','226','227','228','229','230','231','232','233','234','235','236','237','238','239','240','241','242','243','244','245','246','247','248','249','250','251','252','253','254','255','256','257','258','259','260','261','262','263','264','265','266','267','268','269','270','271','272','273','274','275','276','277','278','279','280','281','282','283','284','285','286','287','288','289','290','291','292','293','294','295','296','297','298','299','300','301','302','303','304','305','306','307','308','309','310','311','312','313','314','315','316','317','318','319','320','321','322','323','324','325','326','327','328','329','330','331','332','333','334','335','336','337','338','339','340','341','342','343','344','345','346','347','348','349','350','351','352','353','354','355','356','357','358','359','360','361','362','363','364','365','366','367','368','369','370','371','372','373','374','375','376','377','378','379','380','381','382','383','384','385','386','387','388','389','390','391','392','393','394','395','396','397','398','399','400','401','402','403','404','405','406','407','408','409','410','411','412','413','414','415','416','417','418','419','420','421','422','423','424','425','426','427','428','429','430','431','432','433','434','435','436','437','438','439','440','441','442','443','444','445','446','447','448','449','450','451','452','453','454','455','456','457','458','459','460','461','462','463','464','465','466','467','468'};
all_sources ={'1','2','3','4','5','6','7','8','9','9','9','9','10','10','10','10','11','11','11','11','12','12','12','18','17','16','13','14','15','19','20','20','21','27','26','25','24','22','23','28','28','29','29','30','30','36','35','34','33','31','32','37','37','38','38','39','39','45','44','43','42','40','41','46','46','47','47','48','48','54','53','52','51','49','50','55','56','56','57','57','63','62','61','60','58','59','64','64','65','65','66','66','72','71','70','69','67','68','73','73','74','74','75','75','81','80','79','78','76','77','82','82','83','83','84','84','86','87','89','90','91','92','93','94','95','96','97','98','99','100','101','102','103','104','105','106','107','108','109','110','111','112','113','114','115','116','117','118','119','120','121','122','123','124','125','126','127','128','129','130','131','132','133','134','135','136','137','138','139','140','141','142','143','144','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192','193','194','195','196','197','198','199','200','201','202','203','204','205','206','207','208','209','210','211','212','213','214','215','216','217','218','219','220','221','222','223','224','225','226','227','228','229','230','231','232','233','234','235','236','237','238','239','240','241','242','243','244','245','246','247','248','249','250','251','252','253','254','255','256','257','258','259','260','261','262','263','264','265','266','267','268','269','270','271','271','272','273','274','275','276','277','278','279','280','281','282','283','284','285','286','287','288','289','290','291','292','293','294','295','296','297','298','299','300','301','302','303','304','304','305','306','306','307','308','309','310','311','312','312','313','314','315','315','316','317','318','319','320','321','322','323','324','325','326','327','328','329','330','331','332','333','334','335','336','337','338','339','340','341','342','343','344','345','346','347','347','348','349','350','351','352','353','354','355','356','357','358','359','360','361','362','363','364','365','366','367','368','369','370','371','371','372','373','374','375','376','377','378','379','380','381','382','383','384','385','386','387','388','389','390','391','392','393','394','395','396','397','398','399','400','401','402','403','404','405','406','407','408','409','410','411','412','413','414','415','416','417','418','419','420','421','422','423','424','424','425','426','427','428','429','430','431','432','433','434','435','436','437','438','439','440','441','442','443','444','445','446','447','448','449','450','451','452','453','454','455','456','457','458','459','460','461','462','463','464','465','466','467','468','468'};
all_targets = {'111','9','101','10','112','11','134','139','3','5','7','8','5','7','8','1','7','8','1','3','1','3','5','21','146','20','145','19','20','17','17','13','13','30','119','29','147','288','28','24','26','26','22','22','24','39','107','38','113','114','37','33','35','35','31','31','33','48','89','47','98','90','46','42','44','44','40','40','42','57','91','56','104','308','55','53','53','49','49','51','66','148','65','144','129','64','60','62','62','58','58','60','75','124','74','110','95','73','69','71','71','67','67','69','84','92','83','87','85','82','78','80','80','76','76','78','77','45','79','54','41','93','94','68','96','97','81','99','100','4','102','103','43','105','106','36','108','109','52','2','70','34','6','115','116','117','118','27','120','121','122','123','32','125','126','127','128','59','130','131','132','133','72','135','136','137','138','16','140','141','142','143','15','14','61','25','18','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','198','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192','193','194','195','196','197','63','199','200','201','202','203','204','205','206','207','208','209','210','211','212','213','214','215','216','217','218','219','220','221','222','223','224','225','226','227','228','229','230','267','232','233','234','235','236','237','238','239','240','241','242','243','244','245','246','247','248','249','250','251','252','253','254','255','256','257','258','259','260','261','262','263','264','265','266','172','268','269','270','271','272','302','273','274','275','276','277','278','279','280','281','282','283','284','285','286','287','23','289','290','291','292','293','294','295','296','297','298','299','300','301','302','303','304','305','343','306','307','231','267','309','310','311','312','313','375','314','315','316','426','317','318','319','320','321','322','323','324','325','326','327','328','329','330','331','332','333','334','335','336','337','338','339','340','341','342','305','344','345','346','347','348','399','349','350','351','352','353','354','355','356','357','358','359','360','361','362','363','364','365','366','367','368','369','370','371','372','425','373','374','51','376','377','378','379','380','381','382','383','384','385','386','387','388','389','390','391','392','393','394','395','396','397','398','338','400','401','402','403','404','405','406','407','408','409','410','411','412','413','414','415','416','417','418','419','420','421','422','423','424','425','372','50','427','428','429','430','431','432','433','434','435','436','437','438','439','440','441','442','443','444','445','446','447','448','449','450','451','452','453','454','455','456','457','458','459','460','461','462','463','464','465','466','467','468','234','228'};
[source_found, s] = ismember(all_sources, all_ids);
[target_found, t] = ismember(all_targets, all_ids);
x=[-4.88359740000000,-4.88359740000000,-4.30359750000000,-3.93359760000000,-3.35359740000000,-3.35359740000000,-3.93359760000000,-4.30359750000000,-4.12359760000000,-4.12359760000000,-4.12359760000000,-4.12359760000000,-3.37359760000000,-3.37359760000000,-3.94359760000000,-4.30359750000000,-4.87359760000000,-4.87359760000000,-4.12359760000000,-4.12359760000000,-4.12359760000000,-1.71359740000000,-2.08359740000000,-2.64359740000000,-2.64359740000000,-1.71359740000000,-2.08359740000000,-1.89359720000000,-1.89359720000000,-1.89359720000000,-1.71359740000000,-2.07359770000000,-2.63359760000000,-2.63359760000000,-1.71359740000000,-2.07359770000000,-1.89359720000000,-1.89359720000000,-1.89359720000000,-4.86359740000000,-4.86359740000000,-4.29359700000000,-3.93359760000000,-3.37359760000000,-3.37359760000000,-4.11359740000000,-4.11359740000000,-4.11359740000000,-2.65359760000000,-2.65359760000000,-2.08359740000000,-1.72359720000000,-1.15359750000000,-1.15359750000000,-1.90359750000000,-1.90359750000000,-1.90359750000000,-6.53359750000000,-6.16359760000000,-5.60359760000000,-5.60359760000000,-6.53359750000000,-6.16359760000000,-6.34359740000000,-6.34359740000000,-6.34359740000000,-6.53359750000000,-6.16359760000000,-5.60359760000000,-5.60359760000000,-6.53359750000000,-6.16359760000000,-6.34359740000000,-6.34359740000000,-6.34359740000000,-6.53359750000000,-6.16359760000000,-5.60359760000000,-5.60359760000000,-6.53359750000000,-6.16359760000000,-6.34359740000000,-6.34359740000000,-6.34359740000000,-6.52359720000000,-6.15359740000000,-5.22359750000000,-5.24359750000000,-2.99359750000000,-3.03359750000000,-6.16359760000000,-6.16359760000000,-6.16359760000000,-6.52359720000000,-6.52359720000000,-6.52359720000000,-3.93359760000000,-3.93359760000000,-3.93359760000000,-4.30359750000000,-4.31359700000000,-4.30359750000000,-1.71359740000000,-1.71359740000000,-1.71359740000000,-2.07359770000000,-2.08359740000000,-2.09359770000000,-5.22359750000000,-5.26359750000000,-2.98359750000000,-3.02359750000000,-1.71359740000000,-1.71359740000000,-1.71359740000000,-1.71359740000000,-1.71359740000000,-2.07359770000000,-2.07359770000000,-2.07359770000000,-2.06359740000000,-2.06359740000000,-6.16359760000000,-6.17359730000000,-6.17359730000000,-6.17359730000000,-6.17359730000000,-6.53359750000000,-6.53359750000000,-6.54359700000000,-6.53359750000000,-6.54359700000000,-3.93359760000000,-3.94359760000000,-3.94359760000000,-3.94359760000000,-3.95359750000000,-4.30359750000000,-4.31359700000000,-4.31359700000000,-4.31359700000000,-4.31359700000000,-5.22359750000000,-5.25359730000000,-3.00359750000000,-3.02359750000000,-6.16359760000000,-6.16359760000000,-6.16359760000000,-6.15359740000000,-6.15359740000000,-6.15359740000000,-6.15359740000000,-6.16359760000000,-6.15359740000000,-5.96359730000000,-5.63359740000000,-5.25359730000000,-4.87359760000000,-4.50359730000000,-4.12359760000000,-3.74359750000000,-3.37359760000000,-2.99359750000000,-2.61359760000000,-2.23359750000000,-1.86359750000000,-1.48359740000000,-1.10359730000000,-0.733597400000000,-0.723597170000000,-1.10359730000000,-1.48359740000000,-1.86359750000000,-2.24359770000000,-2.62359740000000,-3.00359750000000,-3.38359760000000,-3.77359750000000,-4.15359740000000,-4.53359750000000,-4.91359760000000,-5.29359700000000,-5.67359730000000,-6.03359750000000,-6.32359740000000,-6.48359730000000,-6.53359750000000,-6.54359700000000,-6.53359750000000,-6.53359750000000,-6.54359700000000,-6.54359700000000,-6.53359750000000,-6.53359750000000,-6.53359750000000,-0.353597300000000,0.0264028090000000,0.396402700000000,0.776402830000000,1.15640300000000,1.53640310000000,1.90640300000000,2.28640300000000,2.66640200000000,3.03640300000000,3.41640200000000,3.79640220000000,4.15640300000000,4.47640280000000,4.73640300000000,5.01640270000000,5.36640300000000,5.74640230000000,6.11640300000000,6.44640300000000,6.71640250000000,6.87640240000000,6.94640300000000,6.86640300000000,6.72640280000000,6.45640230000000,6.12640240000000,5.74640230000000,5.36640300000000,4.98640300000000,4.60640300000000,4.22640280000000,3.84640240000000,3.85640260000000,4.22640280000000,4.60640300000000,4.98640300000000,5.35640300000000,5.73640300000000,6.10640300000000,6.46640250000000,6.75640250000000,7.01640270000000,7.19640300000000,7.29640250000000,7.29640250000000,7.20640230000000,7.03640300000000,6.77640300000000,6.48640300000000,6.12640240000000,5.75640250000000,5.37640240000000,5.00640250000000,4.67640260000000,4.41640230000000,4.14640300000000,3.78640300000000,3.40640280000000,3.02640270000000,2.64640260000000,2.26640250000000,1.88640250000000,1.50640240000000,1.12640230000000,0.746402600000000,0.366402480000000,-0.0235973820000000,-0.403597500000000,3.47640250000000,3.18640260000000,2.81640270000000,2.46640230000000,2.22640250000000,1.84640250000000,1.46640240000000,1.07640300000000,0.696402430000000,0.316402760000000,-0.0635973440000000,-0.443597470000000,-0.823597550000000,-1.20359720000000,-1.57359760000000,-1.85359730000000,-2.03359770000000,-2.09359770000000,-2.09359770000000,-2.09359770000000,-2.09359770000000,-1.71359740000000,-1.71359740000000,-1.71359740000000,-1.71359740000000,-1.57359760000000,-1.27359740000000,-0.893597250000000,-0.513597600000000,-0.143597260000000,0.236402380000000,0.616402500000000,0.996402600000000,1.36640300000000,1.74640210000000,2.12640210000000,2.40640280000000,2.75640230000000,3.12640210000000,3.41640200000000,3.51640250000000,-0.783597600000000,-0.463597450000000,-0.113597535000000,0.256402340000000,0.636402500000000,1.01640260000000,1.39640270000000,1.75640240000000,2.10640260000000,2.43640260000000,2.74640200000000,3.03640300000000,3.30640240000000,3.52640270000000,3.72640250000000,3.88640240000000,4.02640300000000,4.09640260000000,4.14640300000000,4.13640260000000,4.09640260000000,3.99640200000000,3.87640210000000,3.74640200000000,3.62640210000000,3.54640220000000,3.48640280000000,3.45640200000000,3.44640280000000,3.43640260000000,3.43640260000000,3.43640260000000,3.37640210000000,3.16640200000000,3.04640220000000,2.69640280000000,2.66640200000000,2.45640200000000,2.33640220000000,2.32640300000000,2.31640270000000,2.32640300000000,2.33640220000000,2.35640260000000,2.39640260000000,2.45640200000000,2.54640220000000,2.63640240000000,2.77640270000000,2.91640200000000,2.99640200000000,3.01640250000000,2.99640200000000,2.91640200000000,2.76640250000000,2.56640270000000,2.31640270000000,2.03640300000000,1.71640240000000,1.35640280000000,0.986402400000000,0.606402750000000,0.226402630000000,-0.153597490000000,-0.543597340000000,-0.923597460000000,-1.30359760000000,0.816402800000000,1.18640270000000,1.55640260000000,1.90640300000000,2.23640280000000,2.54640220000000,2.83640220000000,3.08640220000000,3.28640300000000,3.49640200000000,3.63640240000000,3.72640250000000,3.77640270000000,3.76640250000000,3.70640200000000,3.61640290000000,3.49640200000000,3.36640290000000,3.25640230000000,3.17640230000000,3.10640260000000,3.06640270000000,3.05640240000000,3.04640220000000,2.56640270000000,2.69640280000000,2.70640200000000,2.70640200000000,2.75640230000000,2.81640270000000,2.89640260000000,2.99640200000000,3.13640240000000,3.25640230000000,3.35640260000000,3.39640260000000,3.39640260000000,3.32640300000000,3.20640200000000,3.03640300000000,2.82640300000000,2.58640220000000,2.31640270000000,1.98640290000000,1.63640250000000,1.26640260000000,0.886402500000000,0.506402400000000,0.126402720000000,-0.253597400000000,-0.633597500000000,2.10640260000000,2.48640280000000,2.85640260000000,3.23640280000000,3.60640260000000,3.95640200000000,4.27640300000000,4.58640240000000,4.85640300000000,5.11640300000000,5.43640300000000,5.81640300000000,6.19640300000000,6.54640250000000,6.83640240000000,7.01640270000000,7.08640240000000,6.97640280000000,6.73640300000000,6.40640300000000,6.02640300000000,5.64640300000000,5.30640270000000,5.04640250000000,4.88640260000000,4.85640300000000,4.95640230000000,5.17640260000000,5.34640260000000,5.46640250000000,5.62640240000000,5.90640300000000,6.22640280000000,6.39640300000000,6.44640300000000,6.34640260000000,6.11640300000000,5.77640300000000,5.43640300000000,5.14640300000000,4.95640230000000,4.88640260000000,4.88640260000000];
y=[-2.70582460000000,-3.06582430000000,-3.64582420000000,-3.64582420000000,-3.06582430000000,-2.70582460000000,-2.12582470000000,-2.12582470000000,-2.88582400000000,-2.88582400000000,-2.88582400000000,-2.88582400000000,1.15417550000000,0.784175600000000,0.224175630000000,0.224175630000000,1.15417550000000,0.784175600000000,0.974175630000000,0.974175630000000,0.974175630000000,0.214175400000000,0.214175400000000,0.774175800000000,1.14417580000000,1.70417570000000,1.70417570000000,0.954175650000000,0.954175650000000,0.954175650000000,-3.62582470000000,-3.62582470000000,-3.05582400000000,-2.69582440000000,-2.13582400000000,-2.13582400000000,-2.87582470000000,-2.87582470000000,-2.87582470000000,-5.96582400000000,-5.59582420000000,-5.03582500000000,-5.03582500000000,-5.96582400000000,-5.59582420000000,-5.78582500000000,-5.78582500000000,-5.78582500000000,-5.96582400000000,-5.59582420000000,-5.03582500000000,-5.03582500000000,-5.96582400000000,-5.59582420000000,-5.78582500000000,-5.78582500000000,-5.78582500000000,1.72417570000000,1.72417570000000,1.15417550000000,0.794175800000000,0.224175630000000,0.224175630000000,0.974175630000000,0.974175630000000,0.974175630000000,-2.13582400000000,-2.13582400000000,-2.69582440000000,-3.06582430000000,-3.62582470000000,-3.62582470000000,-2.88582400000000,-2.88582400000000,-2.88582400000000,-5.03582500000000,-5.03582500000000,-5.59582420000000,-5.96582400000000,-6.52582450000000,-6.52582450000000,-5.78582500000000,-5.78582500000000,-5.78582500000000,-6.90582470000000,-6.90582470000000,-5.97582440000000,-5.59582420000000,-5.97582440000000,-5.60582450000000,-4.65582470000000,-4.27582450000000,-3.89582420000000,-4.00582500000000,-4.38582400000000,-4.75582500000000,-4.65582470000000,-4.27582450000000,-3.89582420000000,-4.02582450000000,-4.40582470000000,-4.77582450000000,-4.65582470000000,-4.27582450000000,-3.89582420000000,-3.99582460000000,-4.37582500000000,-4.75582500000000,-3.07582450000000,-2.70582460000000,-3.07582450000000,-2.69582440000000,-1.74582460000000,-1.36582450000000,-0.985824400000000,-0.605824300000000,-0.225824180000000,-0.165824230000000,-0.545824800000000,-0.915824700000000,-1.29582480000000,-1.67582390000000,-1.75582480000000,-1.37582470000000,-0.995824640000000,-0.615824500000000,-0.225824180000000,-0.145824250000000,-0.525824370000000,-0.905824500000000,-1.27582430000000,-1.65582440000000,-1.74582460000000,-1.36582450000000,-0.985824400000000,-0.595824060000000,-0.215824430000000,-1.74582460000000,-1.36582450000000,-0.985824400000000,-0.595824060000000,-0.215824430000000,0.794175800000000,1.15417550000000,0.784175600000000,1.14417580000000,2.10417580000000,2.48417540000000,2.86417560000000,3.24417570000000,3.62417580000000,4.00417570000000,4.38417530000000,4.76417540000000,5.14417550000000,5.47417550000000,5.65417580000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.68417550000000,5.68417550000000,5.68417550000000,5.68417550000000,5.68417550000000,5.68417550000000,5.67417570000000,5.67417570000000,5.66417550000000,6.05417540000000,6.05417540000000,6.05417540000000,6.04417560000000,6.04417560000000,6.05417540000000,6.05417540000000,6.05417540000000,6.05417540000000,6.04417560000000,6.04417560000000,6.04417560000000,6.04417560000000,6.03417540000000,5.91417550000000,5.65417580000000,5.31417560000000,4.93417550000000,4.56417560000000,4.18417550000000,3.80417560000000,3.43417570000000,3.05417560000000,2.67417550000000,2.30417560000000,1.92417550000000,5.66417550000000,5.66417550000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.67417570000000,5.68417550000000,5.79417560000000,6.00417570000000,6.27417560000000,6.52417560000000,6.67417570000000,6.70417550000000,6.61417600000000,6.43417550000000,6.16417550000000,5.82417540000000,5.45417550000000,5.08417560000000,4.73417570000000,4.46417570000000,4.27417560000000,4.20417550000000,4.20417550000000,4.22417550000000,4.21417570000000,4.20417550000000,4.20417550000000,3.82417560000000,3.82417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.89417580000000,4.03417540000000,4.27417560000000,4.55417540000000,4.88417530000000,5.25417570000000,5.63417530000000,6.00417570000000,6.34417600000000,6.63417600000000,6.87417550000000,7.01417540000000,7.07417600000000,7.03417540000000,6.91417550000000,6.73417570000000,6.45417550000000,6.18417550000000,6.05417540000000,6.05417540000000,6.05417540000000,6.04417560000000,6.04417560000000,6.03417540000000,6.03417540000000,6.02417560000000,6.01417540000000,6.02417560000000,6.02417560000000,6.04417560000000,4.32417540000000,4.57417540000000,4.66417550000000,4.51417540000000,4.23417570000000,4.20417550000000,4.21417570000000,4.22417550000000,4.22417550000000,4.21417570000000,4.19417570000000,4.19417570000000,4.20417550000000,4.19417570000000,4.09417530000000,3.83417560000000,3.50417540000000,3.13417550000000,2.75417540000000,2.38417550000000,2.00417540000000,2.08417580000000,2.46417550000000,2.84417560000000,3.22417570000000,3.58417580000000,3.81417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.83417560000000,3.82417560000000,3.82417560000000,3.57417560000000,3.41417570000000,3.41417570000000,3.66417570000000,4.02417560000000,-6.00582500000000,-6.20582500000000,-6.35582450000000,-6.35582450000000,-6.35582450000000,-6.31582450000000,-6.26582430000000,-6.16582500000000,-6.01582430000000,-5.82582470000000,-5.60582450000000,-5.36582470000000,-5.09582420000000,-4.78582500000000,-4.45582500000000,-4.11582470000000,-3.75582480000000,-3.38582400000000,-3.00582480000000,-2.62582470000000,-2.24582460000000,-1.87582470000000,-1.51582410000000,-1.15582440000000,-0.785824600000000,-0.415824700000000,-0.0358245930000000,0.344175520000000,0.724175630000000,1.10417580000000,1.48417540000000,1.86417560000000,2.24417570000000,2.56417580000000,2.92417550000000,3.03417560000000,2.66417570000000,2.33417580000000,1.98417540000000,1.60417580000000,1.22417570000000,0.854175750000000,0.474175630000000,0.0941755200000000,-0.285824600000000,-0.655824500000000,-1.01582410000000,-1.38582400000000,-1.73582430000000,-2.08582470000000,-2.45582460000000,-2.83582470000000,-3.21582400000000,-3.58582470000000,-3.93582420000000,-4.25582500000000,-4.54582500000000,-4.79582500000000,-4.99582500000000,-5.11582470000000,-5.21582400000000,-5.24582500000000,-5.23582460000000,-5.21582400000000,-5.20582500000000,-5.22582440000000,-5.20582500000000,-6.01582430000000,-5.94582460000000,-5.86582470000000,-5.71582400000000,-5.52582450000000,-5.31582450000000,-5.06582450000000,-4.77582450000000,-4.45582500000000,-4.13582400000000,-3.78582450000000,-3.40582440000000,-3.03582450000000,-2.65582440000000,-2.27582430000000,-1.90582440000000,-1.54582480000000,-1.18582420000000,-0.815824330000000,-0.445824440000000,-0.0658243300000000,0.314175780000000,0.694175400000000,1.07417560000000,1.30417560000000,0.954175650000000,0.574175540000000,0.204175650000000,-0.175824460000000,-0.545824800000000,-0.915824700000000,-1.28582450000000,-1.63582400000000,-1.99582460000000,-2.35582420000000,-2.73582430000000,-3.11582450000000,-3.48582430000000,-3.84582400000000,-4.18582440000000,-4.49582500000000,-4.78582500000000,-5.05582430000000,-5.24582500000000,-5.39582440000000,-5.50582500000000,-5.56582450000000,-5.58582500000000,-5.59582420000000,-5.58582500000000,-5.60582450000000,-6.30582430000000,-6.34582420000000,-6.33582500000000,-6.30582430000000,-6.21582400000000,-6.07582470000000,-5.86582470000000,-5.65582470000000,-5.38582400000000,-5.10582450000000,-4.90582470000000,-4.87582500000000,-4.89582440000000,-4.76582430000000,-4.52582450000000,-4.19582460000000,-3.81582430000000,-3.44582440000000,-3.15582440000000,-2.95582460000000,-2.91582470000000,-2.85582420000000,-2.69582440000000,-2.41582470000000,-2.06582430000000,-1.67582390000000,-1.31582430000000,-0.995824640000000,-0.665824700000000,-0.295824830000000,0.0441758070000000,0.304175560000000,0.524175800000000,0.854175750000000,1.23417540000000,1.60417580000000,1.91417570000000,2.07417560000000,2.24417570000000,2.50417540000000,2.83417580000000,3.21417550000000,3.59417560000000];
EdgeTable = table([s.', t.'], ones(length(s),1), 'VariableNames', {'EndNodes' 'Weight'});
NodeTable = table(all_names.', 'VariableNames',{'Name'});
figure()
G = digraph(EdgeTable,NodeTable);
p=plot(G,'XData',x,'YData',y);
axis square
xlabel('x')
ylabel('y')
title('BFMC track')
[path,d, edgepath] = shortestpath(G,228,231);
highlight(p,'Edges',edgepath)

Accepted Answer

Christine Tobler
Christine Tobler on 11 Apr 2022
Try putting the node numbers in quotes:
[path,d, edgepath] = shortestpath(G,"228","231");
You have given each node a name, and while the first few nodes have names that match their number, that's not true for all of them. By inserting strings instead of numbers, shortestpath will look up the nodes in the G.Nodes.Name variable instead of taking the nodes that match positions 228 and 231 in the Name variable.

More Answers (0)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!