COIN-OR::LEMON - Graph Library

Changeset 2386:81b47fc5c444 in lemon-0.x for lemon/graph_adaptor.h


Ignore:
Timestamp:
03/02/07 19:04:28 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
Message:

Hard Warning checking

  • based on the remark of the ZIB user
  • we do not use -Winline
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_adaptor.h

    r2384 r2386  
    9494
    9595    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
    96     Edge findEdge(const Node& source, const Node& target,
     96    Edge findEdge(const Node& u, const Node& v,
    9797                  const Edge& prev = INVALID) {
    98       return graph->findEdge(source, target, prev);
     98      return graph->findEdge(u, v, prev);
    9999    }
    100100 
     
    103103    }
    104104
    105     Edge addEdge(const Node& source, const Node& target) const {
    106       return Edge(graph->addEdge(source, target));
     105    Edge addEdge(const Node& u, const Node& v) const {
     106      return Edge(graph->addEdge(u, v));
    107107    }
    108108
     
    115115    int id(const Edge& e) const { return graph->id(e); }
    116116
    117     Node fromNodeId(int id) const {
    118       return graph->fromNodeId(id);
    119     }
    120 
    121     Edge fromEdgeId(int id) const {
    122       return graph->fromEdgeId(id);
     117    Node fromNodeId(int ix) const {
     118      return graph->fromNodeId(ix);
     119    }
     120
     121    Edge fromEdgeId(int ix) const {
     122      return graph->fromEdgeId(ix);
    123123    }
    124124
     
    244244
    245245    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
    246     Edge findEdge(const Node& source, const Node& target,
     246    Edge findEdge(const Node& u, const Node& v,
    247247                  const Edge& prev = INVALID) {
    248       return Parent::findEdge(target, source, prev);
     248      return Parent::findEdge(v, u, prev);
    249249    }
    250250
     
    461461                             template NodeMap<_Value> > Parent;
    462462   
    463       NodeMap(const Graph& graph)
    464         : Parent(graph) {}
    465       NodeMap(const Graph& graph, const _Value& value)
    466         : Parent(graph, value) {}
     463      NodeMap(const Graph& g)
     464        : Parent(g) {}
     465      NodeMap(const Graph& g, const _Value& v)
     466        : Parent(g, v) {}
    467467   
    468468      NodeMap& operator=(const NodeMap& cmap) {
     
    487487                             template EdgeMap<_Value> > Parent;
    488488   
    489       EdgeMap(const Graph& graph)
    490         : Parent(graph) {}
    491       EdgeMap(const Graph& graph, const _Value& value)
    492         : Parent(graph, value) {}
     489      EdgeMap(const Graph& g)
     490        : Parent(g) {}
     491      EdgeMap(const Graph& g, const _Value& v)
     492        : Parent(g, v) {}
    493493   
    494494      EdgeMap& operator=(const EdgeMap& cmap) {
     
    634634                             template NodeMap<_Value> > Parent;
    635635   
    636       NodeMap(const Graph& graph)
    637         : Parent(graph) {}
    638       NodeMap(const Graph& graph, const _Value& value)
    639         : Parent(graph, value) {}
     636      NodeMap(const Graph& g)
     637        : Parent(g) {}
     638      NodeMap(const Graph& g, const _Value& v)
     639        : Parent(g, v) {}
    640640   
    641641      NodeMap& operator=(const NodeMap& cmap) {
     
    660660                             template EdgeMap<_Value> > Parent;
    661661   
    662       EdgeMap(const Graph& graph)
    663         : Parent(graph) {}
    664       EdgeMap(const Graph& graph, const _Value& value)
    665         : Parent(graph, value) {}
     662      EdgeMap(const Graph& g)
     663        : Parent(g) {}
     664      EdgeMap(const Graph& g, const _Value& v)
     665        : Parent(g, v) {}
    666666   
    667667      EdgeMap& operator=(const EdgeMap& cmap) {
     
    11061106      typedef SubMapExtender<Adaptor, EdgeMapBase<_Value> > Parent;
    11071107   
    1108       EdgeMap(const Graph& graph)
    1109         : Parent(graph) {}
    1110       EdgeMap(const Graph& graph, const _Value& value)
    1111         : Parent(graph, value) {}
     1108      EdgeMap(const Graph& g)
     1109        : Parent(g) {}
     1110      EdgeMap(const Graph& g, const _Value& v)
     1111        : Parent(g, v) {}
    11121112   
    11131113      EdgeMap& operator=(const EdgeMap& cmap) {
     
    11811181      : Parent(), edge_notifier(*this), edge_notifier_proxy(*this) {}
    11821182
    1183     void setGraph(_Graph& graph) {
    1184       Parent::setGraph(graph);
    1185       edge_notifier_proxy.setNotifier(graph.notifier(GraphEdge()));
     1183    void setGraph(_Graph& g) {
     1184      Parent::setGraph(g);
     1185      edge_notifier_proxy.setNotifier(g.notifier(GraphEdge()));
    11861186    }
    11871187
     
    12211221      }
    12221222
    1223       void setNotifier(typename Graph::EdgeNotifier& notifier) {
    1224         Parent::attach(notifier);
     1223      void setNotifier(typename Graph::EdgeNotifier& nf) {
     1224        Parent::attach(nf);
    12251225      }
    12261226
     
    12361236      virtual void add(const std::vector<GraphEdge>& ge) {
    12371237        std::vector<Edge> edges;
    1238         for (int i = 0; i < (int)ge.size(); ++i) {
     1238        for (int i = 0; i < int(ge.size()); ++i) {
    12391239          edges.push_back(AdaptorBase::Parent::direct(ge[i], true));
    12401240          edges.push_back(AdaptorBase::Parent::direct(ge[i], false));
     
    12501250      virtual void erase(const std::vector<GraphEdge>& ge) {
    12511251        std::vector<Edge> edges;
    1252         for (int i = 0; i < (int)ge.size(); ++i) {
     1252        for (int i = 0; i < int(ge.size()); ++i) {
    12531253          edges.push_back(AdaptorBase::Parent::direct(ge[i], true));
    12541254          edges.push_back(AdaptorBase::Parent::direct(ge[i], false));
     
    18221822    };
    18231823
    1824     void first(Node& node) const {
    1825       Parent::first(node);
    1826       node.in_node = true;
    1827     }
    1828 
    1829     void next(Node& node) const {
    1830       if (node.in_node) {
    1831         node.in_node = false;
     1824    void first(Node& n) const {
     1825      Parent::first(n);
     1826      n.in_node = true;
     1827    }
     1828
     1829    void next(Node& n) const {
     1830      if (n.in_node) {
     1831        n.in_node = false;
    18321832      } else {
    1833         node.in_node = true;
    1834         Parent::next(node);
    1835       }
    1836     }
    1837 
    1838     void first(Edge& edge) const {
    1839       edge.item.setSecond();
    1840       Parent::first(edge.item.second());
    1841       if (edge.item.second() == INVALID) {
    1842         edge.item.setFirst();
    1843         Parent::first(edge.item.first());
    1844       }
    1845     }
    1846 
    1847     void next(Edge& edge) const {
    1848       if (edge.item.secondState()) {
    1849         Parent::next(edge.item.second());
    1850         if (edge.item.second() == INVALID) {
    1851           edge.item.setFirst();
    1852           Parent::first(edge.item.first());
     1833        n.in_node = true;
     1834        Parent::next(n);
     1835      }
     1836    }
     1837
     1838    void first(Edge& e) const {
     1839      e.item.setSecond();
     1840      Parent::first(e.item.second());
     1841      if (e.item.second() == INVALID) {
     1842        e.item.setFirst();
     1843        Parent::first(e.item.first());
     1844      }
     1845    }
     1846
     1847    void next(Edge& e) const {
     1848      if (e.item.secondState()) {
     1849        Parent::next(e.item.second());
     1850        if (e.item.second() == INVALID) {
     1851          e.item.setFirst();
     1852          Parent::first(e.item.first());
    18531853        }
    18541854      } else {
    1855         Parent::next(edge.item.first());
     1855        Parent::next(e.item.first());
    18561856      }     
    18571857    }
    18581858
    1859     void firstOut(Edge& edge, const Node& node) const {
    1860       if (node.in_node) {
    1861         edge.item.setSecond(node);
     1859    void firstOut(Edge& e, const Node& n) const {
     1860      if (n.in_node) {
     1861        e.item.setSecond(n);
    18621862      } else {
    1863         edge.item.setFirst();
    1864         Parent::firstOut(edge.item.first(), node);
    1865       }
    1866     }
    1867 
    1868     void nextOut(Edge& edge) const {
    1869       if (!edge.item.firstState()) {
    1870         edge.item.setFirst(INVALID);
     1863        e.item.setFirst();
     1864        Parent::firstOut(e.item.first(), n);
     1865      }
     1866    }
     1867
     1868    void nextOut(Edge& e) const {
     1869      if (!e.item.firstState()) {
     1870        e.item.setFirst(INVALID);
    18711871      } else {
    1872         Parent::nextOut(edge.item.first());
     1872        Parent::nextOut(e.item.first());
    18731873      }     
    18741874    }
    18751875
    1876     void firstIn(Edge& edge, const Node& node) const {
    1877       if (!node.in_node) {
    1878         edge.item.setSecond(node);       
     1876    void firstIn(Edge& e, const Node& n) const {
     1877      if (!n.in_node) {
     1878        e.item.setSecond(n);       
    18791879      } else {
    1880         edge.item.setFirst();
    1881         Parent::firstIn(edge.item.first(), node);
    1882       }
    1883     }
    1884 
    1885     void nextIn(Edge& edge) const {
    1886       if (!edge.item.firstState()) {
    1887         edge.item.setFirst(INVALID);
     1880        e.item.setFirst();
     1881        Parent::firstIn(e.item.first(), n);
     1882      }
     1883    }
     1884
     1885    void nextIn(Edge& e) const {
     1886      if (!e.item.firstState()) {
     1887        e.item.setFirst(INVALID);
    18881888      } else {
    1889         Parent::nextIn(edge.item.first());
    1890       }
    1891     }
    1892 
    1893     Node source(const Edge& edge) const {
    1894       if (edge.item.firstState()) {
    1895         return Node(Parent::source(edge.item.first()), false);
     1889        Parent::nextIn(e.item.first());
     1890      }
     1891    }
     1892
     1893    Node source(const Edge& e) const {
     1894      if (e.item.firstState()) {
     1895        return Node(Parent::source(e.item.first()), false);
    18961896      } else {
    1897         return Node(edge.item.second(), true);
    1898       }
    1899     }
    1900 
    1901     Node target(const Edge& edge) const {
    1902       if (edge.item.firstState()) {
    1903         return Node(Parent::target(edge.item.first()), true);
     1897        return Node(e.item.second(), true);
     1898      }
     1899    }
     1900
     1901    Node target(const Edge& e) const {
     1902      if (e.item.firstState()) {
     1903        return Node(Parent::target(e.item.first()), true);
    19041904      } else {
    1905         return Node(edge.item.second(), false);
    1906       }
    1907     }
    1908 
    1909     int id(const Node& node) const {
    1910       return (Parent::id(node) << 1) | (node.in_node ? 0 : 1);
    1911     }
    1912     Node nodeFromId(int id) const {
    1913       return Node(Parent::nodeFromId(id >> 1), (id & 1) == 0);
     1905        return Node(e.item.second(), false);
     1906      }
     1907    }
     1908
     1909    int id(const Node& n) const {
     1910      return (Parent::id(n) << 1) | (n.in_node ? 0 : 1);
     1911    }
     1912    Node nodeFromId(int ix) const {
     1913      return Node(Parent::nodeFromId(ix >> 1), (ix & 1) == 0);
    19141914    }
    19151915    int maxNodeId() const {
     
    19171917    }
    19181918
    1919     int id(const Edge& edge) const {
    1920       if (edge.item.firstState()) {
    1921         return Parent::id(edge.item.first()) << 1;
     1919    int id(const Edge& e) const {
     1920      if (e.item.firstState()) {
     1921        return Parent::id(e.item.first()) << 1;
    19221922      } else {
    1923         return (Parent::id(edge.item.second()) << 1) | 1;
    1924       }
    1925     }
    1926     Edge edgeFromId(int id) const {
    1927       if ((id & 1) == 0) {
    1928         return Edge(Parent::edgeFromId(id >> 1));
     1923        return (Parent::id(e.item.second()) << 1) | 1;
     1924      }
     1925    }
     1926    Edge edgeFromId(int ix) const {
     1927      if ((ix & 1) == 0) {
     1928        return Edge(Parent::edgeFromId(ix >> 1));
    19291929      } else {
    1930         return Edge(Parent::nodeFromId(id >> 1));
     1930        return Edge(Parent::nodeFromId(ix >> 1));
    19311931      }
    19321932    }
     
    19391939    ///
    19401940    /// Returns true when the node is in-node.
    1941     static bool inNode(const Node& node) {
    1942       return node.in_node;
     1941    static bool inNode(const Node& n) {
     1942      return n.in_node;
    19431943    }
    19441944
     
    19461946    ///
    19471947    /// Returns true when the node is out-node.
    1948     static bool outNode(const Node& node) {
    1949       return !node.in_node;
     1948    static bool outNode(const Node& n) {
     1949      return !n.in_node;
    19501950    }
    19511951
     
    19531953    ///
    19541954    /// Returns true when the edge is edge in the original graph.
    1955     static bool origEdge(const Edge& edge) {
    1956       return edge.item.firstState();
     1955    static bool origEdge(const Edge& e) {
     1956      return e.item.firstState();
    19571957    }
    19581958
     
    19601960    ///
    19611961    /// Returns true when the edge binds an in-node and an out-node.
    1962     static bool bindEdge(const Edge& edge) {
    1963       return edge.item.secondState();
     1962    static bool bindEdge(const Edge& e) {
     1963      return e.item.secondState();
    19641964    }
    19651965
     
    19671967    ///
    19681968    /// Gives back the in-node created from the \c node.
    1969     static Node inNode(const GraphNode& node) {
    1970       return Node(node, true);
     1969    static Node inNode(const GraphNode& n) {
     1970      return Node(n, true);
    19711971    }
    19721972
     
    19741974    ///
    19751975    /// Gives back the out-node created from the \c node.
    1976     static Node outNode(const GraphNode& node) {
    1977       return Node(node, false);
     1976    static Node outNode(const GraphNode& n) {
     1977      return Node(n, false);
    19781978    }
    19791979
     
    19811981    ///
    19821982    /// Gives back the edge binds the two part of the node.
    1983     static Edge edge(const GraphNode& node) {
    1984       return Edge(node);
     1983    static Edge edge(const GraphNode& n) {
     1984      return Edge(n);
    19851985    }
    19861986
     
    19881988    ///
    19891989    /// Gives back the edge of the original edge.
    1990     static Edge edge(const GraphEdge& edge) {
    1991       return Edge(edge);
     1990    static Edge edge(const GraphEdge& e) {
     1991      return Edge(e);
    19921992    }
    19931993
     
    20062006    typedef True FindEdgeTag;
    20072007
    2008     Edge findEdge(const Node& source, const Node& target,
     2008    Edge findEdge(const Node& u, const Node& v,
    20092009                  const Edge& prev = INVALID) const {
    2010       if (inNode(source)) {
    2011         if (outNode(target)) {
    2012           if ((GraphNode&)source == (GraphNode&)target && prev == INVALID) {
    2013             return Edge(source);
     2010      if (inNode(u)) {
     2011        if (outNode(v)) {
     2012          if (static_cast<const GraphNode&>(u) ==
     2013              static_cast<const GraphNode&>(v) && prev == INVALID) {
     2014            return Edge(u);
    20142015          }
    20152016        }
    20162017      } else {
    2017         if (inNode(target)) {
    2018           return Edge(findEdge(*Parent::graph, source, target, prev));
     2018        if (inNode(v)) {
     2019          return Edge(findEdge(*Parent::graph, u, v, prev));
    20192020        }
    20202021      }
     
    21922193      virtual void add(const std::vector<GraphNode>& gn) {
    21932194        std::vector<Node> nodes;
    2194         for (int i = 0; i < (int)gn.size(); ++i) {
     2195        for (int i = 0; i < int(gn.size()); ++i) {
    21952196          nodes.push_back(AdaptorBase::Parent::inNode(gn[i]));
    21962197          nodes.push_back(AdaptorBase::Parent::outNode(gn[i]));
     
    22082209      virtual void erase(const std::vector<GraphNode>& gn) {
    22092210        std::vector<Node> nodes;
    2210         for (int i = 0; i < (int)gn.size(); ++i) {
     2211        for (int i = 0; i < int(gn.size()); ++i) {
    22112212          nodes.push_back(AdaptorBase::Parent::inNode(gn[i]));
    22122213          nodes.push_back(AdaptorBase::Parent::outNode(gn[i]));
     
    22542255        node_notifier_proxy(*this), edge_notifier_proxy(*this) {}
    22552256   
    2256     void setGraph(_Graph& graph) {
    2257       Parent::setGraph(graph);
    2258       node_notifier_proxy.setNotifier(graph.notifier(GraphNode()));
    2259       edge_notifier_proxy.setNotifier(graph.notifier(GraphEdge()));
     2257    void setGraph(_Graph& g) {
     2258      Parent::setGraph(g);
     2259      node_notifier_proxy.setNotifier(g.notifier(GraphNode()));
     2260      edge_notifier_proxy.setNotifier(g.notifier(GraphEdge()));
    22602261    }
    22612262
     
    23082309        std::vector<Node> nodes;
    23092310        std::vector<Edge> edges;
    2310         for (int i = 0; i < (int)gn.size(); ++i) {
     2311        for (int i = 0; i < int(gn.size()); ++i) {
    23112312          edges.push_back(AdaptorBase::Parent::edge(gn[i]));
    23122313          nodes.push_back(AdaptorBase::Parent::inNode(gn[i]));
     
    23262327        std::vector<Node> nodes;
    23272328        std::vector<Edge> edges;
    2328         for (int i = 0; i < (int)gn.size(); ++i) {
     2329        for (int i = 0; i < int(gn.size()); ++i) {
    23292330          edges.push_back(AdaptorBase::Parent::edge(gn[i]));
    23302331          nodes.push_back(AdaptorBase::Parent::inNode(gn[i]));
     
    23362337      virtual void build() {
    23372338        std::vector<Edge> edges;
    2338         const typename Parent::Notifier* notifier = Parent::notifier();
     2339        const typename Parent::Notifier* nf = Parent::notifier();
    23392340        GraphNode it;
    2340         for (notifier->first(it); it != INVALID; notifier->next(it)) {
     2341        for (nf->first(it); it != INVALID; nf->next(it)) {
    23412342          edges.push_back(AdaptorBase::Parent::edge(it));
    23422343        }
     
    23462347      virtual void clear() {
    23472348        std::vector<Edge> edges;
    2348         const typename Parent::Notifier* notifier = Parent::notifier();
     2349        const typename Parent::Notifier* nf = Parent::notifier();
    23492350        GraphNode it;
    2350         for (notifier->first(it); it != INVALID; notifier->next(it)) {
     2351        for (nf->first(it); it != INVALID; nf->next(it)) {
    23512352          edges.push_back(AdaptorBase::Parent::edge(it));
    23522353        }
     
    23862387      virtual void add(const std::vector<GraphEdge>& ge) {
    23872388        std::vector<Edge> edges;
    2388         for (int i = 0; i < (int)ge.size(); ++i) {
     2389        for (int i = 0; i < int(ge.size()); ++i) {
    23892390          edges.push_back(AdaptorBase::edge(ge[i]));
    23902391        }
     
    23962397      virtual void erase(const std::vector<GraphEdge>& ge) {
    23972398        std::vector<Edge> edges;
    2398         for (int i = 0; i < (int)ge.size(); ++i) {
     2399        for (int i = 0; i < int(ge.size()); ++i) {
    23992400          edges.push_back(AdaptorBase::edge(ge[i]));
    24002401        }
     
    24032404      virtual void build() {
    24042405        std::vector<Edge> edges;
    2405         const typename Parent::Notifier* notifier = Parent::notifier();
     2406        const typename Parent::Notifier* nf = Parent::notifier();
    24062407        GraphEdge it;
    2407         for (notifier->first(it); it != INVALID; notifier->next(it)) {
     2408        for (nf->first(it); it != INVALID; nf->next(it)) {
    24082409          edges.push_back(AdaptorBase::Parent::edge(it));
    24092410        }
     
    24122413      virtual void clear() {
    24132414        std::vector<Edge> edges;
    2414         const typename Parent::Notifier* notifier = Parent::notifier();
     2415        const typename Parent::Notifier* nf = Parent::notifier();
    24152416        GraphEdge it;
    2416         for (notifier->first(it); it != INVALID; notifier->next(it)) {
     2417        for (nf->first(it); it != INVALID; nf->next(it)) {
    24172418          edges.push_back(AdaptorBase::Parent::edge(it));
    24182419        }
     
    25102511    ///
    25112512    /// Constructor of the adaptor.
    2512     SplitGraphAdaptor(_Graph& graph) {
    2513       Parent::setGraph(graph);
     2513    SplitGraphAdaptor(_Graph& g) {
     2514      Parent::setGraph(g);
    25142515    }
    25152516
Note: See TracChangeset for help on using the changeset viewer.