Last active
February 11, 2018 19:16
-
-
Save drewxa/620747f53c2b36dfefdc8662abf46e4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#pragma once | |
#include <set> | |
template <class CostType, class VertexId> | |
class Graph | |
{ | |
public: | |
Graph(); | |
~Graph(); | |
void AddVertex(const VertexId& v); | |
void AddEdge(const VertexId& out, const VertexId& in, CostType cost); | |
void AddBidirectiveEdge(const VertexId& v1, const VertexId& v2, CostType cost); | |
void AddEdge(const VertexId& out, const VertexId& in, CostType cost, bool bidirective); | |
size_t VerteciesCount() const; | |
size_t EdgesCount() const; | |
size_t VertexDegree(const VertexId& v) const; | |
std::set<std::pair<VertexId, VertexId>> Edges() const; | |
std::set<VertexId> Vertices() const; | |
std::set<VertexId> AdjacentVertices(const VertexId&) const; | |
std::set<std::pair<VertexId, VertexId>> AdjacentEdges(const VertexId&) const; | |
CostType Cost(const VertexId& out, const VertexId& in) const; | |
private: | |
}; | |
template <class T> | |
using Path = std::vector<T>; | |
template <class C, class T> | |
using Info = std::pair<C, Path<T>>; | |
template <class CostType, class VertexId> | |
std::map<VertexId, Info<CostType, VertexId> Dijkstra(const Graph<CostType, VertexId>& gr, const VertexId& source); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment