Algorithmen_Datenstrukturen/Uebung 3/Uebung3_1/extendedgraph.h

69 lines
3.0 KiB
C++

#include <iostream> /* cout, cerr */
#include <limits.h> /* INT_MAX */
#include <sstream> /* type stringstream to easily concat a result string */
#include <string> /* type string */
#include <vector> /* type vector */
#include "edge.h"
#pragma once
void vectorToString(std::vector<std::string> vector);
/* -- Class Graph -- */
class ExtendedGraph {
private:
std::vector<std::string> vertices; // vector connecting vertices with
// indicies; needed for name resolution
int minDistance(int dist[], bool sptSet[]);
void printPath(int parent[], int j, int dist[], int &sum);
public:
ExtendedGraph(); // default constructor
ExtendedGraph(const std::vector<std::string> &vertices,
const std::vector<Edge> &edges); // param. constructor
std::vector<std::vector<int>>
adjacencyMatrix; // vector of vectors containing integers (the adjacency
// matrix)
/* --
Resolves a given string of a vertex and returns its position in the
adjacencyMatrix (as integer). Returns -1 if name could not be resolved,
which indicates the the name was not found.
-- */
int resolveVertex(const std::string &name);
void
printGraph(); // prints out the graph with vertices and the adjacencyMatrix
/* --
Graph Manipulation Functions
-- */
void insertVertex(
const std::string &vertex); // inserts a new vertex; throws error, if
// vertex already exists in Graph
void deleteVertex(
const std::string &vertex); // deletes a vertex from the Graph; throws an
// error, if vertex does not exist
void insertEdge(
const Edge &edge); // inserts a new edge; parameter can be {std::string,
// std::string} due to implicit cast...
// ...does not check if the edge already exists, nor
// notifies user/programmer
void deleteEdge(
const Edge &edge); // deletes an edge; parameter can be {std::string,
// std::string} due to implicit cast...
// ...does not check if edge exists
bool adjacent(const std::string &vertex1,
const std::string
&vertex2); // checks if vertex1 and vertex2 are adjacent;
// returns boolean; adjacency indicates that...
// ...a direct connection between a <--> b
// (direction NOT important) exists
std::vector<std::string>
neighbours(const std::string
&vertex); // returns a vector of strings, containing all
// neighbouring vertices of the parameter vertex...
// ...Neighbours are all vertices that a given
// vertex is connected to through OUTGOING edges
void performDijkstraPath(std::string sourceVertex, std::string targetVertex);
};