next up previous contents
Next: Cellular automata micro-simulation Up: Street network data and Previous: Links input   Contents

Incoming/outgoing links

In order to traverse the graph, for each node we need the incoming and the outgoing links. Recall that for links we already have the corresponding information, i.e. the fromNodes and toNodes. The construction of the inLinks and outLinks is as follows:

First, add the corresponding entries to the node class:


{}
class Node {
private:
    ...
    typedef vector<Link*> VLinks; 
    Vlinks outLinks_;
    Vlinks inLinks_;
public:
    ...
    void addOutLink(Link* Link) { outLinks_.push_back(link); }
    Link* outLink(int i) { return outLinks_[i]; }
    int nOutLinks() { return outLinks_.size(); }

    void addInLink(Link* link) { inLinks_.push_back(link); }
    Link* inLink(int i) { return inLinks_[i]; }
    int nInLinks() { return inLinks_.size() ; }
} ;

Note that we do not need the associative array property here for outLinks_ or inLinks_, and so we use the vector class instead of map.

Next, we generate the information of which links are incoming and outgoing. The easiest way is to add this in the readLinks routine at the end, as was already done in the previous section.

Task 6.4   Add the information about incoming/outgoing links to your code.

Task 6.5   Test if you can read the network in


        http://www.matsim.org/files/studies/corridor/network

without errors.


next up previous contents
Next: Cellular automata micro-simulation Up: Street network data and Previous: Links input   Contents
2004-02-02