MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
hypergraphlib_arc.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// hypergraphlib_arc.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:54:00 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 #include <iostream>
23 
24 #pragma hdrstop
25 
26 #include "hypergraphlib_platform.h"
27 #include "hypergraphlib_arc.h"
28 #include "hypergraphlib_graph.h"
29 #include "hypergraphlib_node.h"
30 
31 
32 namespace HypergraphLib {
33 
34 Arc::Arc(Graph * __owner, int __id)
35  : GraphObject (__owner, __id)
36 {
37 }
38 
39 Arc::Arc(const Arc &__from, Graph * __owner)
40  : GraphObject(__from, __owner)
41 {
42  for (Arc::MultimapNodesById::const_iterator it = __from._nodes.begin();
43  it != __from._nodes.end();
44  it++)
45  {
46  Node * n = _owner->GetNode(it->first);
47  if (n)
48  {
49  Add (n);
50  }
51  }
52 }
53 
55 {
56 
57 }
58 
59 void Arc::Add (Node * __node)
60 {
61  _nodes.insert ( Int_Node_Pair ( __node->Id(), __node ));
62 }
63 
64 int Arc::Remove (Node * __node)
65 {
66  return Remove (__node->Id());
67 }
68 
69 int Arc::Remove (int __id)
70 {
71  int result=0;
72  MultimapNodesById::iterator it;
73  for (it = _nodes.find ( __id );
74  it != _nodes.end();
75  it = _nodes.find ( __id ), result++)
76  _nodes.erase ( it );
77 
78  /*while(it!=_nodes.end())
79  {
80  _nodes.erase ( it );
81  it = _nodes.find ( __id );
82  }*/
83 
84  return result;
85 }
86 
87 int Arc::Rank () const
88 {
89  return _nodes.size();
90 }
91 
92 int Arc::NodeCount(int __id) const
93 {
94  return _nodes.count(__id);
95 }
96 
98 {
99  return _nodes;
100 }
101 
102 Node * Arc::First() const
103 {
104  MultimapNodesById::const_iterator it = _nodes.begin();
105  return it->second;
106 }
107 
108 Node * Arc::Last() const
109 {
110  MultimapNodesById::const_iterator it = _nodes.end();
111  it--;
112  return it->second;
113 }
114 
115 bool Arc::IsLoopOfNode(int __NodeId)
116 {
117  return (NodeCount(__NodeId ) == 2);
118 }
119 
121 {
122  return (_nodes.size() == 2 && First() == Last() );
123 }
124 
125 }
126 
HypergraphLib::Arc::Arc
Arc(Graph *__owner, int __id)
Definition: hypergraphlib_arc.cpp:34
HypergraphLib::Arc::IsLoop
bool IsLoop()
Definition: hypergraphlib_arc.cpp:120
HypergraphLib::Arc::Last
Node * Last() const
Definition: hypergraphlib_arc.cpp:108
HypergraphLib::Arc::Add
void Add(Node *)
Definition: hypergraphlib_arc.cpp:59
hypergraphlib_arc.h
HypergraphLib::Arc::MultimapNodesById
std::multimap< int, Node * > MultimapNodesById
Definition: hypergraphlib_arc.h:39
HypergraphLib::Arc
Definition: hypergraphlib_arc.h:37
HypergraphLib
Definition: hypergraphlib_arc.cpp:32
hypergraphlib_graph.h
HypergraphLib::Arc::First
Node * First() const
Definition: hypergraphlib_arc.cpp:102
HypergraphLib::Arc::Remove
int Remove(int __id)
Definition: hypergraphlib_arc.cpp:69
HypergraphLib::Arc::_nodes
MultimapNodesById _nodes
Definition: hypergraphlib_arc.h:100
HypergraphLib::Arc::IsLoopOfNode
bool IsLoopOfNode(int __NodeId)
Definition: hypergraphlib_arc.cpp:115
HypergraphLib::GraphObject::_owner
const Graph * _owner
Definition: hypergraphlib_graphobject.h:42
HypergraphLib::GraphObject
Definition: hypergraphlib_graphobject.h:31
HypergraphLib::Arc::~Arc
~Arc()
Definition: hypergraphlib_arc.cpp:54
HypergraphLib::Arc::Rank
int Rank() const
Definition: hypergraphlib_arc.cpp:87
HypergraphLib::GraphObject::Id
int Id() const
Definition: hypergraphlib_graphobject.cpp:47
HypergraphLib::Arc::NodeCount
int NodeCount(int) const
Definition: hypergraphlib_arc.cpp:92
hypergraphlib_platform.h
HypergraphLib::Node
Definition: hypergraphlib_node.h:35
HypergraphLib::Graph::GetNode
Node * GetNode(int) const
Definition: hypergraphlib_graph.cpp:175
hypergraphlib_node.h
HypergraphLib::Arc::Int_Node_Pair
std::pair< int, Node * > Int_Node_Pair
Definition: hypergraphlib_arc.h:40
HypergraphLib::Arc::Nodes
MultimapNodesById & Nodes()
Definition: hypergraphlib_arc.cpp:97