Skip to content

Commit

Permalink
Started Graph class.
Browse files Browse the repository at this point in the history
Signed-off-by: saad0105050 <saad0105050@gmail.com>
  • Loading branch information
saad0105050 committed Sep 22, 2014
1 parent a83208d commit 34f5001
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions YASI_12/YASI_12.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<ClInclude Include="ds.comparable.h" />
<ClInclude Include="ds.dictionary.h" />
<ClInclude Include="ds.doublylinkedlist.h" />
<ClInclude Include="ds.graph.h" />
<ClInclude Include="ds.hashtablebase.h" />
<ClInclude Include="ds.HopScotchHashTable.h" />
<ClInclude Include="ds.IntLinearProbingHashTable.h" />
Expand Down
6 changes: 6 additions & 0 deletions YASI_12/YASI_12.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<Filter Include="Header Files\Common">
<UniqueIdentifier>{d2827f3c-736f-4f2a-891c-9fa2883e5685}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Graph">
<UniqueIdentifier>{9d029d58-d806-4503-8f54-cc27d0b9332d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand Down Expand Up @@ -128,5 +131,8 @@
<ClInclude Include="ds.HopScotchHashTable.h">
<Filter>Header Files\Dictionary</Filter>
</ClInclude>
<ClInclude Include="ds.graph.h">
<Filter>Header Files\Graph</Filter>
</ClInclude>
</ItemGroup>
</Project>
49 changes: 49 additions & 0 deletions YASI_12/ds.graph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
#include "common.h"
#include "ds.doublylinkedlist.h"
using namespace std;

namespace yasi{
namespace ds{

// forward declarations
class VertexBase;
class EdgeBase;

template<class V, class Element>
struct Edge{
Element element;
V *pStart, *pEnd;
};

template<class E>
typedef DoublyLinkedList< E > EdgeList;

template<class Element, class EdgeElement>
struct Vertex{
protected:
typedef Vertex<Element, EdgeElement> self;
typedef Edge<self, EdgeElement> edge;
public:
typedef DoublyLinkedList< edge > EdgeList;
int id;
Element element;
EdgeList* pInEdges;
EdgeList* pOutEdges;
};

/// Adjacency list data structure
template<class VertexElement, class EdgeElement>
class Graph{
public:
typedef Vertex<VertexElement, EdgeElement> VertexType;
typedef Edge<VertexType, EdgeElement> EdgeType;
typedef DoublyLinkedList<VertexType*> VertexList;
typedef DoublyLinkedList<EdgeType*> EdgeList;
protected:
VertexList* vertexList;
EdgeList* edgeList;
};

}
}

0 comments on commit 34f5001

Please sign in to comment.