Roomba Controller Dashboard 1
A GUI and TCP client application that is used to control a Roomba for Computer Engineering 2880 @ Iowa State
Loading...
Searching...
No Matches
Graph< V > Class Template Reference

#include <Graph.hpp>

Classes

struct  CustomCompare
 

Public Member Functions

void addNode (Node< V > *newNode)
 
void addNode (Node< V > *nextNode, std::vector< Node< V > * > adjacentNodes, double weight)
 
void addNode (Node< V > *nextNode, std::vector< Node< V > * > adjacentNodes)
 
void addNode (Node< V > *nextNode, Node< V > *nodeITSLATE)
 
void addConnection (Node< V > *one, Node< V > *two, double weight)
 
void addConnection (Node< V > *one, Node< V > *two)
 
void addNode (Node< V > *nextNode, Node< V > *nodeITSLATE, double weight)
 
void setHead (int index)
 
void removeNode (size_t index)
 
std::vector< Node< V > * > Dijkstra (Node< V > *from, Node< V > *find)
 
std::vector< std::vector< double > > getAdjacencyList ()
 
std::vector< Node< V > * > getAdj (Node< V > *next)
 
std::vector< Node< V > * > getNodes ()
 
 Graph ()
 
 ~Graph ()
 

Protected Types

typedef std::pair< double, std::vector< Node< V > * > > pair
 

Protected Member Functions

void resize ()
 
int numVisited (std::vector< bool > listOfBools)
 
bool contains (Node< V > *node, std::vector< Node< V > * > listOfNodes)
 

Protected Attributes

std::vector< Node< V > * > nodes
 
std::vector< std::vector< double > > matrix
 
Node< V > * head = nullptr
 
std::map< Node< V > *, unsigned intnodeMap
 

Detailed Description

template<typename V>
class Graph< V >

Definition at line 17 of file Graph.hpp.

Member Typedef Documentation

◆ pair

template<typename V >
typedef std::pair<double, std::vector<Node<V>*> > Graph< V >::pair
protected

Definition at line 19 of file Graph.hpp.

Constructor & Destructor Documentation

◆ Graph()

template<typename V >
Graph< V >::Graph ( )

Definition at line 14 of file Graph.cpp.

◆ ~Graph()

template<typename V >
Graph< V >::~Graph ( )

Definition at line 254 of file Graph.cpp.

Member Function Documentation

◆ addConnection() [1/2]

template<typename V >
void Graph< V >::addConnection ( Node< V > * one,
Node< V > * two )

Add a connection between two nodes

Parameters
onenode one
twonode two

Definition at line 277 of file Graph.cpp.

◆ addConnection() [2/2]

template<typename V >
void Graph< V >::addConnection ( Node< V > * one,
Node< V > * two,
double weight )

add a weight between nodes

Parameters
onethe first node
twothe second node
weightthe weight to put between them

Definition at line 267 of file Graph.cpp.

◆ addNode() [1/5]

template<typename V >
void Graph< V >::addNode ( Node< V > * newNode)

Add a node to the graph

Parameters
newNodea new node to add to the graph

Definition at line 102 of file Graph.cpp.

◆ addNode() [2/5]

template<typename V >
void Graph< V >::addNode ( Node< V > * nextNode,
Node< V > * nodeITSLATE )

Add a node with a connection

Parameters
nextNodethe node to add
nodeITSLATEa node to add a connection to

Definition at line 132 of file Graph.cpp.

◆ addNode() [3/5]

template<typename V >
void Graph< V >::addNode ( Node< V > * nextNode,
Node< V > * nodeITSLATE,
double weight )

Add a node with a weight to the graph

Parameters
nextNodethe node to add
nodeITSLATEthe node to connect to
weightthe weight between those vertices

Definition at line 282 of file Graph.cpp.

◆ addNode() [4/5]

template<typename V >
void Graph< V >::addNode ( Node< V > * nextNode,
std::vector< Node< V > * > adjacentNodes )

Add a node

Parameters
nextNode
adjacentNodes

Definition at line 127 of file Graph.cpp.

◆ addNode() [5/5]

template<typename V >
void Graph< V >::addNode ( Node< V > * nextNode,
std::vector< Node< V > * > adjacentNodes,
double weight )

Adds a node with adjacent nodes all with the same weight

Parameters
nextNodethe node to add
adjacentNodesthe nodes to make a connect for
weightthe weight for all the edges

Definition at line 111 of file Graph.cpp.

◆ contains()

template<typename V >
bool Graph< V >::contains ( Node< V > * node,
std::vector< Node< V > * > listOfNodes )
protected

Returns true if the graph containes a node

Parameters
nodethe node to determine if it's inside
listOfNodesthe list of nodes to check against
Returns
whether node is in the list of nodes

Definition at line 87 of file Graph.cpp.

◆ Dijkstra()

template<typename V >
std::vector< Node< V > * > Graph< V >::Dijkstra ( Node< V > * from,
Node< V > * find )

Dijkstra's algorithm

Parameters
fromthe node that you start at
findthe node we want to get to
Returns
a path for the nodes

Definition at line 191 of file Graph.cpp.

◆ getAdj()

template<typename V >
std::vector< Node< V > * > Graph< V >::getAdj ( Node< V > * next)

Get the adjacent nodes of a node

Parameters
nextthe node to get its' connected nodes
Returns
the adjacent nodes

Definition at line 172 of file Graph.cpp.

◆ getAdjacencyList()

template<typename V >
std::vector< std::vector< double > > Graph< V >::getAdjacencyList ( )

get the adjaceency matrix for the graph whihc contains the weigthings

Returns
the matrix for the weights

Definition at line 262 of file Graph.cpp.

◆ getNodes()

template<typename V >
std::vector< Node< V > * > Graph< V >::getNodes ( )
Returns
All the nodes

Definition at line 97 of file Graph.cpp.

◆ numVisited()

template<typename V >
int Graph< V >::numVisited ( std::vector< bool > listOfBools)
protected

get the number of nodes we have visited

Parameters
listOfBoolslist of bools to combine
Returns
the number of nodes visitied

Definition at line 289 of file Graph.cpp.

◆ removeNode()

template<typename V >
void Graph< V >::removeNode ( size_t index)

Remove a node from the graph based on index

Parameters
indexthe index to remove

Definition at line 390 of file Graph.cpp.

◆ resize()

template<typename V >
void Graph< V >::resize ( )
protected

resize the adjacency matrix

Definition at line 79 of file Graph.cpp.

◆ setHead()

template<typename V >
void Graph< V >::setHead ( int index)

Set the head of the graph

Parameters
indexthe index to become head

Definition at line 185 of file Graph.cpp.

Member Data Documentation

◆ head

template<typename V >
Node<V>* Graph< V >::head = nullptr
protected

Definition at line 27 of file Graph.hpp.

◆ matrix

template<typename V >
std::vector<std::vector<double> > Graph< V >::matrix
protected

Definition at line 26 of file Graph.hpp.

◆ nodeMap

template<typename V >
std::map<Node<V>*, unsigned int> Graph< V >::nodeMap
protected

Definition at line 28 of file Graph.hpp.

◆ nodes

template<typename V >
std::vector<Node<V>*> Graph< V >::nodes
protected

Definition at line 25 of file Graph.hpp.


The documentation for this class was generated from the following files: