Home > src > BN_pol_rec > functions > getCostMatrix.m

getCostMatrix

PURPOSE ^

node1Node2Road_noCost = [node1 node2 road_number cost; ...]

SYNOPSIS ^

function [C] = getCostMatrix(node1Node2Road_noCost, nodes)

DESCRIPTION ^

 node1Node2Road_noCost = [node1 node2 road_number cost; ...]
 where nodei = xi yi coordinates
 nodes = [xi yi;... ] list of nodes where the enemy node is assumed to be first in the
 list 
 C = cost matix for all combinations of nodes

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 
0002 
0003 function [C] = getCostMatrix(node1Node2Road_noCost, nodes)
0004  
0005 % node1Node2Road_noCost = [node1 node2 road_number cost; ...]
0006 % where nodei = xi yi coordinates
0007 % nodes = [xi yi;... ] list of nodes where the enemy node is assumed to be first in the
0008 % list
0009 % C = cost matix for all combinations of nodes
0010 
0011 C = 10000.*ones(length(nodes(:,1)), length(nodes(:,1)));
0012 for i = 1:length(nodes(:,1))
0013     C(i,i) = 0;
0014   for j = 1:length(node1Node2Road_noCost(:,1))
0015       if (nodes(i,1) == node1Node2Road_noCost(j,1))&&(nodes(i,2) == node1Node2Road_noCost(j,2))
0016          [idx] = findNodeIndex(node1Node2Road_noCost(j,3), node1Node2Road_noCost(j,4), nodes); 
0017          C(i,idx) = node1Node2Road_noCost(j,6);
0018          C(idx, i) = node1Node2Road_noCost(j,6);
0019       end;
0020   end;
0021 end;
0022          
0023 
0024           
0025

Generated on Wed 16-Mar-2005 09:17:47 by m2html © 2003