ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/HypergraphLib_Arc.cpp
Revision: 113
Committed: Wed Jun 25 18:44:12 2008 UTC (16 years, 10 months ago) by francois
Original Path: magic/lib/outil/outil/src/HypergraphLib_Arc.cpp
File size: 1842 byte(s)
Log Message:
pb de compatibilite windows apres le passage linux de hypergraph

File Contents

# User Rev Content
1 francois 113 #include "gestionversion.h"
2 francois 102 #ifdef WINDOWS_VERSION
3 foucault 27 #include <iostream>
4    
5     #pragma hdrstop
6     #include "HypergraphLib_platform.h"
7    
8     #include "HypergraphLib_Arc.h"
9     #include "HypergraphLib_Graph.h"
10     #include "HypergraphLib_Node.h"
11    
12    
13     namespace HypergraphLib {
14    
15     Arc::Arc(Graph * __owner, int __id)
16     : GraphObject (__owner, __id)
17     {
18     }
19    
20     Arc::Arc(const Arc &__from, Graph * __owner)
21     : GraphObject(__from, __owner)
22     {
23     for (Arc::MultimapNodesById::const_iterator it = __from._nodes.begin();
24     it != __from._nodes.end();
25     it++)
26     {
27     Node * n = _owner->GetNode(it->first);
28     if (n)
29     {
30     Add (n);
31     }
32     }
33     }
34    
35     Arc::~Arc()
36     {
37    
38     }
39    
40     void Arc::Add (Node * __node)
41     {
42     _nodes.insert ( Int_Node_Pair ( __node->Id(), __node ));
43     }
44    
45     int Arc::Remove (Node * __node)
46     {
47     return Remove (__node->Id());
48     }
49    
50     int Arc::Remove (int __id)
51     {
52     int result=0;
53     MultimapNodesById::iterator it;
54     for (it = _nodes.find ( __id );
55     it != _nodes.end();
56     it = _nodes.find ( __id ), result++)
57     _nodes.erase ( it );
58    
59     /*while(it!=_nodes.end())
60     {
61     _nodes.erase ( it );
62     it = _nodes.find ( __id );
63     }*/
64    
65     return result;
66     }
67    
68     int Arc::Rank () const
69     {
70     return _nodes.size();
71     }
72    
73     int Arc::NodeCount(int __id) const
74     {
75     return _nodes.count(__id);
76     }
77    
78     Arc::MultimapNodesById & Arc::Nodes()
79     {
80     return _nodes;
81     }
82    
83     Node * Arc::First() const
84     {
85     MultimapNodesById::const_iterator it = _nodes.begin();
86     return it->second;
87     }
88    
89     Node * Arc::Last() const
90     {
91     MultimapNodesById::const_iterator it = _nodes.end();
92     it--;
93     return it->second;
94     }
95    
96     bool Arc::IsLoopOfNode(int __NodeId)
97     {
98     return (NodeCount(__NodeId ) == 2);
99     }
100    
101     bool Arc::IsLoop()
102     {
103     return (_nodes.size() == 2 && First() == Last() );
104     }
105    
106     }
107 francois 102 #endif