# Graph [Matrix Representation]

Nov 29th, 2017
116
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. class Graph
2. {
4.     int _vertexCount;
5.
6.     void init();
7.
8. public:
9.     Graph(int);
10.     ~Graph();
11.
14.
17.
18.     void removeEdgeUndirected(int, int);
19.     void removeEdgeDirected(int, int);
20.
21.     bool hasEdgeBetween(int, int);
22.     int getVertexCount();
23.     Graph* getTranspose_Matrix();
24.     void display();
25. };
26.
27. Graph::Graph(int count)
28. {
29.     this->_vertexCount = count;
30.     init();
31. }
32.
33. Graph::~Graph()
34. {
35.     for (int i = 0; i < _vertexCount; ++i)
36.     {
38.     }
40. }
41.
42. void Graph::init()
43. {
45.     for (int i = 0; i < _vertexCount; ++i)
46.     {
47.         adjacentMatrix[i] = new int[this->_vertexCount]{ 0 };
48.     }
49. }
50.
51. void Graph::addEdgeUndirected(int i, int j, int cost)
52. {
55. }
56.
57. void Graph::addEdgeUndirected(int i, int j)
58. {
60. }
61.
62. void Graph::removeEdgeUndirected(int i, int j)
63. {
65. }
66.
67. void Graph::addEdgeDirected(int i, int j, int cost)
68. {
70. }
71.
72. void Graph::addEdgeDirected(int i, int j)
73. {
75. }
76.
77. void Graph::removeEdgeDirected(int i, int j)
78. {
80. }
81.
82. bool Graph::hasEdgeBetween(int i, int j)
83. {
85. }
86.
87. int Graph::getVertexCount()
88. {
89.     return this->_vertexCount;
90. }
91.
92. Graph* Graph::getTranspose_Matrix()
93. {
94.     Graph* gT = new Graph(this->_vertexCount);
95.
96.     for (int i = 0; i < this->_vertexCount; ++i)
97.     {
98.         for (int j = 0; j < _vertexCount; ++j)
99.         {
101.         }
102.     }
103.     return gT;
104. }
105.
106. void Graph::display()
107. {
108.     cout << "\nGraph in Matrix:\n----------------\n";
109.     for (int i = 0; i < this->_vertexCount; ++i)
110.     {
111.         for (int j = 0; j < this->_vertexCount; ++j)
112.         {
113.             cout << this->adjacentMatrix[i][j] << " ";
114.         }
115.         cout << endl;
116.     }
117. }
RAW Paste Data