Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by elmigranto ( 16 years ago )
/*  ======================================
 *  GRAPH ROUTINES
 *  (file: graphDefinitions.h)
 *  ======================================
 *  Contains main definitons of project.
 *
 *  UGraph refers Undirected Graph
 *  DGraph refers Directed Graph
 *
 *  © 2010 elmigranto
 */

#ifndef graphDefinitions
#define graphDefinitions

#include <set>
#include <list>
#include <iostream>

typedef unsigned int UINT;


namespace graph {


//=========================================

// 'Common'

typedef std::set<UINT> AdjacencyList;

class Vertex {
public:
 UINT id;
 AdjacencyList alist;

 Vertex(UINT vertext_id);

 friend bool operator ==(const Vertex &v1;, const Vertex &v2;);
};

typedef std::list<Vertex> VerticesList;

struct GraphSummary {
 struct {
  UINT vertices, edges;
 } count;
};

class Graph {
protected:
 VerticesList vertices;
 GraphSummary summary;
public:
 Graph(UINT verticesCount = 0);

 VerticesList::iterator AddVertex(VerticesList::iterator before = NULL, UINT custom_id = 0);
 void DeleteVertex(UINT id);

 void Print();
};

// End of 'Common'

//=========================================

// 'Undirected Graphs'

class UGraph: public Graph {
public:
 UGraph(UINT verticesCount = 0);

 void AddEdge(UINT from, UINT to);
 void DeleteEdge(UINT from, UINT to);
};

// End of 'Undirected Graphs'

//=========================================

// 'Directed Graphs'

class DGraph: public Graph {
public:
 DGraph(UINT verticesCount = 0);

 void AddEdge(UINT from, UINT to);
 void DeleteEdge(UINT from, UINT to);
};

// End of 'Directed Graphs'

//=========================================


} // End of 'namespace graph'

#endif

 

Revise this Paste

Your Name: Code Language: