00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OMC_CIRCUITS_H
00025 #define OMC_CIRCUITS_H
00026
00027 #include "Core.h"
00028 #include "SignedSet.h"
00029 #include "OrientedMatroid.h"
00030 #include "Verifiable.h"
00031 #include "Tuple.h"
00032 #include "Combination.h"
00033 #include "Permutation.h"
00034 #include "Chirotope.h"
00035 #include "Util.h"
00036 #include <iostream>
00037 #include <sstream>
00038 #include <list>
00039 #include <set>
00040 #include <string>
00041 #include <algorithm>
00042 #include <typeinfo>
00043
00044 namespace omc
00045 {
00046 class Circuits : public OrientedMatroid, Verifiable {
00047 public:
00048 Circuits (size_t, size_t);
00049 Circuits (const Chirotope &);
00050 Circuits (const Circuits &);
00051
00052 ~Circuits () { m_Circuit.clear(); };
00053
00054 Circuits* clone () const;
00055
00056 size_t getNumCircuits () const;
00057
00058 void addCircuit (SignedSet);
00059 void addCircuit (const std::string);
00060 void addCircuit (const char*);
00061
00062 void clear ();
00063
00064 void relabel (index_t, index_t);
00065 void relabel (const Permutation &);
00066
00067 void reorient (index_t);
00068 void reorient (const std::set<index_t> &);
00069 void reorient (const Combination &);
00070
00071 void remove (index_t);
00072 void contract (index_t);
00073
00074 bool operator== (const OrientedMatroid &) const;
00075
00076 bool verify ();
00077
00078
00079 typedef std::list<SignedSet>::iterator circuit_iterator;
00080 circuit_iterator circuit_begin ();
00081 circuit_iterator circuit_end ();
00082
00083 typedef std::list<SignedSet>::reverse_iterator reverse_circuit_iterator;
00084 reverse_circuit_iterator circuit_rbegin ();
00085 reverse_circuit_iterator circuit_rend();
00086
00087 protected:
00088 std::list <SignedSet> m_Circuit;
00089
00090 void chirotope2cocircuits (const Chirotope &);
00091
00092 void normalize ();
00093
00094 };
00095
00096
00097 std::ostream & operator<< (std::ostream &, Circuits &);
00098 std::istream & operator>> (std::istream &, Circuits &);
00099
00100
00102 inline Circuits::Circuits (size_t r, size_t n)
00103 : OrientedMatroid (r, n), m_Circuit ()
00104 {}
00105
00107 inline Circuits::Circuits (const Chirotope & Chi)
00108 : OrientedMatroid (Chi.getRank(), Chi.getNumElements()), m_Circuit ()
00109 {
00110 chirotope2cocircuits (Chi);
00111 }
00112
00114 inline Circuits::Circuits (const Circuits & C)
00115 : OrientedMatroid (C.m_rank, C.m_numElements), m_Circuit (C.m_Circuit)
00116 {}
00117
00119 inline Circuits* Circuits::clone () const {
00120 return new Circuits(*this);
00121 }
00122
00124 inline size_t Circuits::getNumCircuits () const {
00125 return m_Circuit.size ();
00126 }
00127
00129 inline void Circuits::addCircuit (const std::string s) {
00130 SignedSet S (s);
00131 addCircuit (S);
00132 }
00133
00135 inline void Circuits::addCircuit (const char* s) {
00136 SignedSet S (s);
00137 addCircuit (S);
00138 }
00139
00141 inline void Circuits::clear () {
00142 m_Circuit.clear ();
00143 }
00144
00146 inline Circuits::circuit_iterator Circuits::circuit_begin () {
00147 return m_Circuit.begin ();
00148 }
00149
00151 inline Circuits::circuit_iterator Circuits::circuit_end () {
00152 return m_Circuit.end ();
00153 }
00154
00156 inline Circuits::reverse_circuit_iterator Circuits::circuit_rbegin () {
00157 return m_Circuit.rbegin ();
00158 }
00159
00161 inline Circuits::reverse_circuit_iterator Circuits::circuit_rend () {
00162 return m_Circuit.rend ();
00163 }
00164
00165 };
00166
00167 #endif // OMC_CIRCUITS_H