Skip to content

Commit

Permalink
Added skeleton class for graph
Browse files Browse the repository at this point in the history
  • Loading branch information
seancyw committed Jan 14, 2017
1 parent 61a26f7 commit 2384373
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions DataStructure/DataStructure.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DoublyLinkedList.h" />
<ClInclude Include="Graph.h" />
<ClInclude Include="HashTable.h" />
<ClInclude Include="LinkedList.h" />
<ClInclude Include="Queue.h" />
Expand Down
3 changes: 3 additions & 0 deletions DataStructure/DataStructure.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<ClInclude Include="DoublyLinkedList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Graph.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand Down
42 changes: 42 additions & 0 deletions DataStructure/Graph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

#ifndef GRAPH_H
#define GRAPH_H

#include <iostream>
#include <string>
#include <vector>

struct Edge {

Edge(const std::string& start, const std::string& end, int cost)
: startEdge(start)
, endEdge(end)
, weight(cost)
{
}

std::string startEdge;
std::string endEdge;
int weight;
};

class Graph
{
public:
void addVertex(const std::string& vertex)
{
vertexList.push_back(vertex);
}

void addEdges(const std::string& start, const std::string& end, int cost)
{
edgeList.push_back( Edge(start, end, cost) );
}


private:
std::vector<std::string> vertexList;
std::vector<Edge> edgeList;
};

#endif

0 comments on commit 2384373

Please sign in to comment.