<commit_before>////////////////////////////////////////////////////////////////////////////////
/// @brief Class for arangodb's graph features. Wrapper around the graph informations
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2014-2015 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author <NAME>
/// @author Copyright 2014-2015, ArangoDB GmbH, Cologne, Germany
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

#include "Basics/JsonHelper.h"
#include "Aql/Graphs.h"
using namespace triagens::basics;
using namespace triagens::aql;

char const* Graph::_attrEdgeDefs = "edgeDefinitions";
char const* Graph::_attrOrphans = "orphanCollections";

// -----------------------------------------------------------------------------
// --SECTION--                                                       Local utils
// -----------------------------------------------------------------------------

void Graph::insertVertexCollectionsFromJsonArray(triagens::basics::Json& arr) {
  for (size_t j = 0; j < arr.size(); ++j) {
    Json c = arr.at(j);
    TRI_ASSERT(c.isString());
    std::string name = JsonHelper::getStringValue(c.json(), "");
    addVertexCollection(name);
  }
}

// -----------------------------------------------------------------------------
// --SECTION--                                                       Graph Class
// -----------------------------------------------------------------------------

std::unordered_set<std::string> const& Graph::vertexCollections () const {
  return _vertexColls;
}

std::unordered_set<std::string> const& Graph::edgeCollections () const {
  return _edgeColls;
}

void Graph::addEdgeCollection (std::string name) {
  _edgeColls.insert(name);
}

void Graph::addVertexCollection (std::string name) {
  _vertexColls.insert(name);
}

triagens::basics::Json Graph::toJson (TRI_memory_zone_t* z,
                           bool verbose) const
{
  triagens::basics::Json json(z, triagens::basics::Json::Object);

  if (_vertexColls.size() > 0) {
    triagens::basics::Json vcn(z, triagens::basics::Json::Array);
    for (auto cn : _vertexColls) {
      vcn.add(triagens::basics::Json(cn));
    }
    json("vertexCollectionNames", vcn);
  }

  if (_edgeColls.size() > 0) {
    triagens::basics::Json ecn(z, triagens::basics::Json::Array);
    for (auto cn : _edgeColls) {
      ecn.add(triagens::basics::Json(cn));
    }
    json("edgeCollectionNames", ecn);
  }

  return json;
}

Graph::Graph(triagens::basics::Json j) : <commit_msg>Indention fix<commit_after>////////////////////////////////////////////////////////////////////////////////
/// @brief Class for arangodb's graph features. Wrapper around the graph informations
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2014-2015 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author <NAME>
/// @author Copyright 2014-2015, ArangoDB GmbH, Cologne, Germany
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

#include "Basics/JsonHelper.h"
#include "Aql/Graphs.h"
using namespace triagens::basics;
using namespace triagens::aql;

char const* Graph::_attrEdgeDefs = "edgeDefinitions";
char const* Graph::_attrOrphans = "orphanCollections";

// -----------------------------------------------------------------------------
// --SECTION--                                                       Local utils
// -----------------------------------------------------------------------------

void Graph::insertVertexCollectionsFromJsonArray(triagens::basics::Json& arr) {
  for (size_t j = 0; j < arr.size(); ++j) {
    Json c = arr.at(j);
    TRI_ASSERT(c.isString());
    std::string name = JsonHelper::getStringValue(c.json(), "");
    addVertexCollection(name);
  }
}

// -----------------------------------------------------------------------------
// --SECTION--                                                       Graph Class
// -----------------------------------------------------------------------------

std::unordered_set<std::string> const& Graph::vertexCollections () const {
  return _vertexColls;
}

std::unordered_set<std::string> const& Graph::edgeCollections () const {
  return _edgeColls;
}

void Graph::addEdgeCollection (std::string name) {
  _edgeColls.insert(name);
}

void Graph::addVertexCollection (std::string name) {
  _vertexColls.insert(name);
}

triagens::basics::Json Graph::toJson (TRI_memory_zone_t* z,
                                      bool verbose) const {
  triagens::basics::Json json(z, triagens::basics::Json::Object);

  if (_vertexColls.size() > 0) {
    triagens::basics::Json vcn(z, triagens::basics::Json::Array);
    for (auto cn : _vertexColls) {
      vcn.add(triagens::basics::Json(cn));
    }
    json("vertexCollectionNames", vcn);
  }

  if (_edgeColls.size() > 0) {
    triagens::basics::Json ecn(z, triagens::basics::Json::Array);
    for (auto cn : _edgeColls) {
      ecn.add(triagens::basics::Json(cn));
    }
    json("edgeCollectionNames", ecn);
  }

  return json;
}

Graph::Graph(triagens::basics::Json j) : 
{'fraction_non_alphanumeric': 0.2678927203065134, 'fraction_numerical': 0.011954022988505748, 'mean_word_length': 1.8510266491917868, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3269168', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1728, 'n_words': 463}