Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/graphFile
Binary file not shown.
99 changes: 99 additions & 0 deletions src/lib/SoDA/inc/algorithm/CBFS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C): 2013-2014 Department of Software Engineering, University of Szeged
*
* Author: David Imre Adam <adam.david.imre@gmail.com>
*
* This file is part of SoDA.
*
* SoDA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SoDA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with SoDA. If not, see <http://www.gnu.org/licenses/>.
*/

#include "data/SoDALibDefs.h"
#include "data/Node.h"

#ifndef CBFS_H
#define CBFS_H

using namespace std;

namespace soda
{
/**
* @brief The CBFS class stores the Breadth First Search related algorithms
*/
class CBFS
{
private:
/**
* @brief Vector of vectors of edges
*/
vector<vector<IndexType>>* m_edges;

/**
* @brief An ordering of edges
*/
vector<IndexType>* m_bfsOrder;

/**
* @brief Creates an ordering of m_edges by BFS algorithm
* @param v The current root element
* @param root The helper container for the visited edges
*/
void BFS(int v, bool visited[]);

/**
* @brief Creates the reversed order of chainElements from root with ending with endNode
* @param root The startpoint
* @param root The ending Node
* @param root The starting point
* @return list of reversed order
*/
list<IndexType>* scrollBackSingleChain(vector<Node*>* chainElements, Node* endNode, IndexType root);

public:
/**
* @brief Constructor of CBFS
* @param m_edges The edges.
*/
CBFS(vector<vector<IndexType>>& m_edges);

/**
* @brief Default destructor
*/
~CBFS();

/**
* @brief Creates an ordering of m_edges by BFS algorithm
* @param root The startpoint
* @return The BFS order
*/
vector<IndexType>* getBFS(IndexType root);

/**
* @brief Creates a list of paths on the m_edges those contains all of the vertices
* @param rootElementId The starting elementId of a vertex
* @return Vector of paths
*/
vector<list<IndexType>*>* getPaths(IndexType rootElementId);

/**
* @brief Checks any nodes have more thane one in degree
* @param root The startpoint
* @return A boolean answer value
*/
bool inDegreeGTOne(IndexType root);
};
}

#endif
85 changes: 85 additions & 0 deletions src/lib/SoDA/inc/algorithm/CDFS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (C): 2013-2014 Department of Software Engineering, University of Szeged
*
* Author: David Imre Adam <adam.david.imre@gmail.com>
*
* This file is part of SoDA.
*
* SoDA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SoDA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with SoDA. If not, see <http://www.gnu.org/licenses/>.
*/

#include "data/SoDALibDefs.h"
#include "data/CBitMatrix.h"

#ifndef CDFS_H
#define CDFS_H

using namespace std;

namespace soda
{
/**
* @brief The CDFS class stores the Depth First Search related algorithms
*/
class CDFS
{
private:
/**
* @brief Vector of vectors of edges
*/
vector<vector<IndexType>>* m_edges;

/**
* @brief An ordering of edges
*/
vector<IndexType>* m_dfsOrder;

/**
* @brief Recursive helper. Executes visiting an a subgraph started with current item
* @param v The current root element
* @param visited The helper container for the visited edges
*/
void recursiveHelper(IndexType current, bool *visited);

/**
* @brief Recursive helper. Executes a search for a circle on graph started by current, helped by visited nodes and recoderer routes.
* @param current The current root element
* @param visited A helper container for the visited nodes
* @param recorded A helper container for the building-up routes
*/
bool hasCycleHelper(IndexType current, bool visited[], bool *recorded);

public:

/**
* @brief Constructor of CDFS
* @param m_edges The edges.
*/
CDFS(vector<vector<IndexType>> &m_edges);
~CDFS();

/**
* @brief Gets the DFS ordering of elements.
* @param root The starting node.
*/
vector<IndexType> *getDFS(IndexType root);

/**
* @brief Gets a logical decision, does graph have circle.
*/
bool hasCycle();
};
}

#endif
158 changes: 158 additions & 0 deletions src/lib/SoDA/inc/data/CChain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Copyright (C): 2013-2014 Department of Software Engineering, University of Szeged
*
* Author: David Imre Adam <adam.david.imre@gmail.com>
*
* This file is part of SoDA.
*
* SoDA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SoDA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with SoDA. If not, see <http://www.gnu.org/licenses/>.
*/

#include <vector>
#include <string>
#include "data/CIDManager.h"
#include "interface/IIterators.h"
#include "interface/IChain.h"
#include "io/CJsonReader.h"

#ifndef CCHAIN_H
#define CCHAIN_H

using namespace std;

namespace soda
{
/**
* @brief The CChain class stores the Chain datastructure
*/
class CChain : public IChain
{
private:

/**
* @brief SoDA container of elements
*/
IIDManager* m_codeElements;

/**
* @brief The container of ordered elements.
*/
vector<String>* m_order;
public:

/**
* @brief Constructor
*/
CChain();

/**
* @brief Destructor
*/
~CChain();

/**
* @brief Gets the count of elements
* @return count
*/
IndexType count();

/**
* @brief Clears the containers
*/
virtual void clear();

/**
* @brief Adds a new element
* @param n The new value of the element
*/
virtual void add(const String& n);

/**
* @brief Adds a vector of new elements to the end of the chain
* @param codeElements The vector of elements
*/
virtual void add(const StringVector& codeElements);

/**
* @brief Removes a value from the containers
* @param n The removable value
*/
virtual void remove(const String& n);

/**
* @brief Does the chain contain the element.
* @param n The new value of the element
* @return the answer
*/
virtual bool contains(const String& n);

/**
* @brief Gets the elementId of the value n
* @param n The requested value
* @return the index of the element
*/
virtual IndexType getId(const String& n);

/**
* @brief Gets the value of the elementId n
* @param n The requested id
* @return the value
*/
virtual String getValue(const IndexType n);

/**
* @brief Gets the first type iterator to the beginnig of chain
* @return the begin-iterator
*/
virtual vector<String>::const_iterator first();

/**
* @brief Gets the last type iterator to the end of chain
* @return the end-iterator
*/
virtual vector<String>::const_iterator end();

/**
* @brief Saves a chain as binary data to the out stream
* @param [IN] out The stream
*/
virtual void save(io::CBinaryIO *out) const;

/**
* @brief Loads chain by binary data from in stream
* @param [IN] in The source stream
*/
virtual void load(io::CSoDAio *in);

/**
* @brief Saves the chain to file
* @param [IN] in The filename
*/
virtual void save(const char * filename) const;

/**
* @brief Loads chain from file
* @param [IN] filename The filename
*/
virtual void load(const char * filename);

/**
* @brief Loads chain from JSON data file
* @param [IN] filename The requested id
*/
virtual void loadJson(const String& path);
};
}

#endif
Loading