Routing with Index OR with ID


#1

Hi,
For having the start and the end nodes of each pipe , According to the flow of water passing through the pipe (in below picture , e.g. start and the end of pipe ‘160’ is Junction97 - junction-71, and start and the end of pipe ‘126’ is Junction71 - junction-78)),I use the following commands :

      d = epanet('’BWSN_Network_1.inp');
     % hydraulic simulation
      res = d.getComputedTimeSeries; % ignore events
      %d.getComputedHydraulicTimeSeries with events.

      flows = res.Flow;
      res_direct = min(flows);
      NodesConnectingLinksID = d.getNodesConnectingLinksID;

      directionsAfterSimulation = {};
      for i = 1:d.getLinkCount
              if res_direct(i) >= 0
                 directionsAfterSimulation(i, :) = NodesConnectingLinksID(i, :);
             else
                directionsAfterSimulation(i, :) = fliplr(NodesConnectingLinksID(i, :));
            end 
      end

    directionsAfterSimulation

Now I want to know What is the population affected if a contaminant is injected at node 71?
I wanted to do it by finding the demand of each node and navigating the water. But I have a problem to finding the demand for each node. I use the following command:

 Res = d.getComputedHydraulicTimeSeries; % Res.Demand (:, 1)% Res.Time

In the above command, the population of that node is reported according to the index of each node.
My problem is that When I follow the path of contaminated water.
Because the population of each node is based on the nodes index, not according to the ID.
I’m wrong in calculating the population at risk.
(in fact I found the paths with the IP but the population with the index)

How can I have routing with indexes?
Or do I have a population with an ID?
Is there a better way to compute the population at risk?

Thanks