-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: saad0105050 <saad0105050@gmail.com>
- Loading branch information
saad0105050
committed
Sep 22, 2014
1 parent
a83208d
commit 34f5001
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
||
} | ||
} |