lemon/full_graph.h
changeset 1163 db1d342a1087
parent 1025 c8fa41fcc4a7
equal deleted inserted replaced
14:3342a5233573 15:e309a2ac68fa
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2010
     5  * Copyright (C) 2003-2013
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
   872     static int id(const Node& v) { return v._id; }
   872     static int id(const Node& v) { return v._id; }
   873     int id(const RedNode& v) const { return v._id; }
   873     int id(const RedNode& v) const { return v._id; }
   874     int id(const BlueNode& v) const { return v._id - _red_num; }
   874     int id(const BlueNode& v) const { return v._id - _red_num; }
   875     static int id(Arc e) { return e._id; }
   875     static int id(Arc e) { return e._id; }
   876     static int id(Edge e) { return e._id; }
   876     static int id(Edge e) { return e._id; }
   877     
   877 
   878     static Node nodeFromId(int id) { return Node(id);}
   878     static Node nodeFromId(int id) { return Node(id);}
   879     static Arc arcFromId(int id) { return Arc(id);}
   879     static Arc arcFromId(int id) { return Arc(id);}
   880     static Edge edgeFromId(int id) { return Edge(id);}
   880     static Edge edgeFromId(int id) { return Edge(id);}
   881 
   881 
   882     bool valid(Node n) const {
   882     bool valid(Node n) const {
   902     }
   902     }
   903 
   903 
   904     int index(BlueNode n) const {
   904     int index(BlueNode n) const {
   905       return n._id - _red_num;
   905       return n._id - _red_num;
   906     }
   906     }
   907         
   907 
   908     void clear() {
   908     void clear() {
   909       _red_num = 0; _blue_num = 0;
   909       _red_num = 0; _blue_num = 0;
   910       _node_num = 0; _edge_num = 0;
   910       _node_num = 0; _edge_num = 0;
   911     }
   911     }
   912 
   912 
   913     Edge edge(const Node& u, const Node& v) const { 
   913     Edge edge(const Node& u, const Node& v) const {
   914       if (u._id < _red_num) {
   914       if (u._id < _red_num) {
   915         if (v._id < _red_num) {
   915         if (v._id < _red_num) {
   916           return Edge(-1);
   916           return Edge(-1);
   917         } else {
   917         } else {
   918           return Edge(u._id + _red_num * (v._id - _red_num));
   918           return Edge(u._id + _red_num * (v._id - _red_num));
   924           return Edge(-1);
   924           return Edge(-1);
   925         }
   925         }
   926       }
   926       }
   927     }
   927     }
   928 
   928 
   929     Arc arc(const Node& u, const Node& v) const { 
   929     Arc arc(const Node& u, const Node& v) const {
   930       if (u._id < _red_num) {
   930       if (u._id < _red_num) {
   931         if (v._id < _red_num) {
   931         if (v._id < _red_num) {
   932           return Arc(-1);
   932           return Arc(-1);
   933         } else {
   933         } else {
   934           return Arc(2 * (u._id + _red_num * (v._id - _red_num)) + 1);
   934           return Arc(2 * (u._id + _red_num * (v._id - _red_num)) + 1);