@@ -52,13 +52,16 @@ class MCMnode;
5252class MCMedge {
5353public:
5454 // Constructor
55- MCMedge (CId eId, MCMnode &src, MCMnode &dst, bool eVisible);
55+ MCMedge (CId eId, MCMnode &src, MCMnode &dst, CDouble w, CDouble d, bool eVisible);
5656 CId id;
5757 bool visible;
5858 MCMnode *src;
5959 MCMnode *dst;
6060 CDouble w;
6161 CDouble d;
62+ bool operator ==(const MCMedge& e) const {
63+ return this ->id == e.id ;
64+ }
6265};
6366
6467using MCMedges = std::list<MCMedge>;
@@ -72,14 +75,17 @@ class MCMnode {
7275 bool visible;
7376 MCMedgeRefs in;
7477 MCMedgeRefs out;
78+ bool operator ==(const MCMnode& n) const {
79+ return this ->id == n.id ;
80+ }
7581};
7682
77- // struct MCMNodeLess {
78- // bool operator()(std::shared_ptr< MCMnode> const &lhs,
79- // std::shared_ptr< MCMnode> const &rhs) const {
80- // return lhs->id < rhs->id;
81- // };
82- // };
83+ struct MCMNodeLess {
84+ bool operator ()(const MCMnode* const &lhs,
85+ const MCMnode* const &rhs) const {
86+ return lhs->id < rhs->id ;
87+ };
88+ };
8389
8490using MCMnodes = std::list<MCMnode>;
8591using MCMnodeRefs = std::list<MCMnode *>;
@@ -99,7 +105,9 @@ class MCMgraph {
99105 MCMgraph &operator =(MCMgraph &&) = delete ;
100106 MCMgraph &operator =(const MCMgraph &other) = delete ;
101107
102- [[nodiscard]] const MCMnodes &getNodes () const { return nodes; };
108+ [[nodiscard]] MCMnodes &getNodes () { return nodes; };
109+ [[nodiscard]] MCMnodeRefs getNodeRefs ();
110+ [[nodiscard]] MCMedgeRefs getEdgeRefs ();
103111
104112 [[nodiscard]] uint nrVisibleNodes () const {
105113 uint nrNodes = 0 ;
@@ -119,7 +127,7 @@ class MCMgraph {
119127 return nullptr ;
120128 };
121129
122- [[nodiscard]] const MCMedges &getEdges () const { return edges; };
130+ [[nodiscard]] MCMedges &getEdges () { return edges; };
123131
124132 MCMedge *getEdge (CId id) {
125133 for (auto &edge : edges) {
@@ -169,17 +177,12 @@ class MCMgraph {
169177 while (!n.out .empty ()) {
170178 this ->removeEdge (**(n.out .begin ()));
171179 }
172-
173180 this ->nodes .remove (n);
174181 }
175182
176183 // Add an edge to the MCMgraph.
177- MCMedge *addEdge (CId id, MCMnode &src, MCMnode &dst, CDouble w, CDouble d) {
178- MCMedge& e = this ->edges .emplace_back (id, true );
179- e.src = &src;
180- e.dst = &dst;
181- e.w = w;
182- e.d = d;
184+ MCMedge *addEdge (CId id, MCMnode &src, MCMnode &dst, CDouble w, CDouble d, bool visible = true ) {
185+ MCMedge& e = this ->edges .emplace_back (id, src, dst, w, d, visible);
183186 src.out .push_back (&e);
184187 dst.in .push_back (&e);
185188 return &e;
@@ -202,12 +205,12 @@ class MCMgraph {
202205 // Note this algorithm does currently not distinguish visible and invisible edges!
203206 std::shared_ptr<MCMgraph> pruneEdges ();
204207
205- [[nodiscard]] CDouble calculateMaximumCycleMeanKarp () const ;
208+ [[nodiscard]] CDouble calculateMaximumCycleMeanKarp ();
206209 [[nodiscard]] CDouble
207- calculateMaximumCycleMeanKarpDouble (const MCMnode **criticalNode = nullptr ) const ;
210+ calculateMaximumCycleMeanKarpDouble (const MCMnode **criticalNode = nullptr );
208211
209212 [[nodiscard]] CDouble calculateMaximumCycleRatioAndCriticalCycleYoungTarjanOrlin (
210- std::shared_ptr<std::vector<MCMedge*>> *cycle = nullptr ) const ;
213+ std::shared_ptr<std::vector<const MCMedge*>> *cycle = nullptr );
211214
212215 [[nodiscard]] std::shared_ptr<MCMgraph> normalize (CDouble mu) const ;
213216 [[nodiscard]] std::shared_ptr<MCMgraph> normalize (const std::map<CId, CDouble> &mu) const ;
@@ -238,7 +241,7 @@ using MCMgraphsIter = MCMgraphs::iterator;
238241 * MCM algorithms work also on this graph (which reduces the execution time
239242 * needed in some of the conversion algorithms).
240243 */
241- void stronglyConnectedMCMgraph (const MCMgraph &g,
244+ void stronglyConnectedMCMgraph (MCMgraph &g,
242245 MCMgraphs &components,
243246 bool includeComponentsWithoutEdges = false );
244247
@@ -253,7 +256,7 @@ void relabelMCMgraph(std::shared_ptr<MCMgraph> g);
253256 * addLongestDelayEdgesToMCMgraph ()
254257 * The function adds additional edges to the graph which express the
255258 * longest path between two nodes crossing one edge with a delay. Edges
256- * with no delay are removed and edges with more then one delay element
259+ * with no delay are removed and edges with more than one delay element
257260 * are converted into a sequence of edges with one delay element.
258261 */
259262void addLongestDelayEdgesToMCMgraph (std::shared_ptr<MCMgraph> g);
0 commit comments