IBM ILOG Dispatcher User's Manual > The Basics > Minimizing the Number of Vehicles > Model > Define the createIloNodes function

You create the nodes in the same way you did in Chapter 2, Modeling a Vehicle Routing Problem, except that you must associate the graph nodes to the instances of IloNode. You use the csv reader functionality to input node data and node coordinate data from csv files. You use the member function IloDispatcherGraph::associatebyCoordsInFile to look up the coordinates of a given IloNode in a csv file and automatically associate it to the graph node with matching coordinates.

Step 6   -  

Associate the graph nodes to the IloNodes

Add the following code after the comment
//Associate the graph nodes to the IloNode

    _graph.associateByCoordsInFile (node, coordFileName);

Here is the complete code for defining the createIloNodes function:

void RoutingModel::createIloNodes(char* nodeFileName, char* coordFileName) {
  IloCsvReader csvNodeReader(_env, nodeFileName);
  IloCsvReader::LineIterator  it(csvNodeReader);
  while(it.ok()) {
    IloCsvLine line = *it;
    char * name = line.getStringByHeader("name");
    IloNode node(_env, line.getFloatByHeader("x"),
        line.getFloatByHeader("y"), 0, name);
    node.setKey(name);

    _graph.associateByCoordsInFile (node, coordFileName);

    ++it;
  }
  csvNodeReader.end();
}