Salome HOME
Implementation of planar symmetry + aggregation methods for MEDFileData+MEDFileUMesh
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_Graph.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 15d0239..ef09141
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #include "MEDPARTITIONER_Graph.hxx"
 
-MEDPARTITIONER::Graph::Graph(MEDPARTITIONER::SkyLineArray *array, int *edgeweight):_graph(array),_partition(0),_edge_weight(edgeweight),_cell_weight(0)
+#include "MEDCouplingSkyLineArray.hxx"
+
+#include <set>
+
+MEDPARTITIONER::Graph::Graph(MEDCoupling::MEDCouplingSkyLineArray *array, int *edgeweight):_graph(array),_partition(0),_edge_weight(edgeweight),_cell_weight(0)
 {
 }
 
@@ -28,3 +32,25 @@ MEDPARTITIONER::Graph::~Graph()
   delete _partition;
   delete _graph;
 }
+
+int MEDPARTITIONER::Graph::nbDomains() const
+{
+  std::set<int> domains;
+  if ( _partition )
+    if ( MEDCoupling::DataArrayInt* array = _partition->getValueArray() )
+    {
+      for ( const int * dom = array->begin(); dom != array->end(); ++dom )
+        domains.insert( *dom );
+    }
+  return domains.size();
+}
+
+const int *MEDPARTITIONER::Graph::getPart() const
+{
+  return _partition->getValue();
+}
+
+int MEDPARTITIONER::Graph::nbVertices() const
+{
+  return _graph->getNumberOf();
+}