#include <Graph.h>
Public Member Functions | |
| Graph (vector< vector< int >> adjacencyMatrix) | |
| Graph (vector< vector< int >> adjacencyMatrix, vector< string > node_names) | |
| Graph (string matlabMatrix) | |
| int | getNumberOfNodes () const |
| int | getNumberOfEdges () |
| void | exportFile (const string fileName, const string data) const |
| void | exportAdjazenzmatrixFile (const string fileName) const |
| string | graphToJson () |
| bool | hasCycle () |
| bool | hasEdge (const int from, const int to) |
| bool | hasPath (const vector< int > path) const |
| const string | getAdjacencyMatrixString () const |
| bool | isDirected () |
| int | getInDeg (int vertexIndex) |
| int | getOutDeg (int vertexIndex) |
| bool | isFreeOfLoops () |
| bool | isMultigraph () |
| bool | isSimple () |
| bool | isComplete () |
| bool | isRegular () |
| bool | isForest () |
| bool | hasConnectivity (int s, int t) |
| string | exportDot () |
| bool | areNeighbours (int from, int to) |
| string | exportDot (vector< int > path) |
Represents a simple or directed graph. Has certain verifiable properties. Its edges are not weighted.
| Graph::Graph | ( | vector< vector< int >> | adjacencyMatrix | ) |
| Graph::Graph | ( | vector< vector< int >> | adjacencyMatrix, |
| vector< string > | node_names | ||
| ) |
| Graph::Graph | ( | string | matlabMatrix | ) |
Constructor for a Graph with a adjacency matrix given in Matlab notation (e.g. [0 0 1; 1 0 0; 1 1 0]).
| matlabMatrix | the matrix in matlab notation |
| bool Graph::areNeighbours | ( | int | from, |
| int | to | ||
| ) |
Returns true, if both given vertices are neighbours in the graph. The direction is only considered in digraphs.
| from | first vertice |
| to | second vertice |
| void Graph::exportAdjazenzmatrixFile | ( | const string | fileName | ) | const |
Export the adjazenmatrix to a file.
| fileName | string file name. |
| string Graph::exportDot | ( | ) |
Exports the Graph to a dot file.
| string Graph::exportDot | ( | vector< int > | path | ) |
Exports the string for a dot file. Takes a path and marks it red in the result dot file.
| path | The path to be colored. |
| void Graph::exportFile | ( | const string | fileName, |
| const string | data | ||
| ) | const |
Export a given file with custom data.
| fileName | string file name. |
| data | string of data. |
| const string Graph::getAdjacencyMatrixString | ( | ) | const |
| int Graph::getInDeg | ( | int | vertexIndex | ) |
Returns indegree indeg(v). Therefore it counts the ingoing edges. In undirected graphs loops are counted twice.
| vertexIndex | the index of the vertex v |
| int Graph::getNumberOfEdges | ( | ) |
Detect the number of edges of the given graph.
| int Graph::getNumberOfNodes | ( | ) | const |
Detect the number of nodes of the given graph.
| int Graph::getOutDeg | ( | int | vertexIndex | ) |
Returns outdegree outdeg(v). Therefore it counts the outgoing edges. In undirected graphs loops are counted twice.
| vertexIndex | the index of the vertex v |
| string Graph::graphToJson | ( | ) |
Return the graph in a json-format.
Transform the graph to json-format.
| bool Graph::hasConnectivity | ( | int | s, |
| int | t | ||
| ) |
Calculates if there is a path from s to t.
| s | number of node 1 |
| t | number of node 2 |
| bool Graph::hasCycle | ( | ) |
Checks the graph if a cycle exists. DFS.
| bool Graph::hasEdge | ( | const int | from, |
| const int | to | ||
| ) |
Checks if the graph contains the given edge.
| from | node number |
| to | node number |
| bool Graph::hasPath | ( | const vector< int > | path | ) | const |
Checks, if the graph contains the given path.
| path | vector with path nodes. |
| bool Graph::isComplete | ( | ) |
Specifies whether the graph is a complete graph (simple graph "in which every pair of distinct vertices is connected by a unique edge."). Checks only undirected graphs! A complete graph is also called K_n.
| bool Graph::isDirected | ( | ) |
Returns if the graph is a directed or undirected graph.
| bool Graph::isForest | ( | ) |
Specifies whether the graph is a directed forest ("A forest is a disjoint union of trees." ).
| bool Graph::isFreeOfLoops | ( | ) |
Specifies whether the graph is free of loops. Loops are edges from and to the same vertex.
| bool Graph::isMultigraph | ( | ) |
Specifies whether the graph is a multigraph (has multiple edges/has "two or more edged that connect the same two vertices")
| bool Graph::isRegular | ( | ) |
Specifies whether the graph is a regular graph ("is a graph where each vertex has the same number of neighbors" ).
| bool Graph::isSimple | ( | ) |
Specifies whether the graph is a simple graph (undirected, no multiple edges, no loops) or not.
1.8.6