CustusX  22.04-rc5
An IGT application
AdjList Class Reference

#include <adjlist.hpp>

Public Member Functions

 AdjList (int nodes)
 
void adjacent (int n1, int n2)
 
void visit (int node)
 
bool isVisited (int node) const
 
int findNext (int node) const
 
vector< int > findAllNext (int node) const
 
int findFirst () const
 
vector< int > findAllFirst () const
 
void print ()
 

Detailed Description

Class representing an adjacency list, with the possibility of marking a node as visited

Definition at line 11 of file adjlist.hpp.

Constructor & Destructor Documentation

AdjList::AdjList ( int  nodes)
inline

Constructor. Initialize an adjacency list and initialize all nodes to unvisited with no neighbours

Parameters
nodesNumber of nodes in graph

Definition at line 27 of file adjlist.hpp.

Member Function Documentation

void AdjList::adjacent ( int  n1,
int  n2 
)
inline

Mark two nodes as adjacent to each other (undirected)

Parameters
n1Node 1
n2Node 2

Definition at line 45 of file adjlist.hpp.

vector<int> AdjList::findAllFirst ( ) const
inline

Find all nodes with only one neighbour

Returns
Vector of all nodes in graph with degree 1

Definition at line 129 of file adjlist.hpp.

vector<int> AdjList::findAllNext ( int  node) const
inline

Find all adjacent nodes that has not been visited yet

Parameters
nodeto find all unvisited adjacent nodes for
Returns
vector of adjacent unvisited nodes, empty vector if no such nodes exists.

Definition at line 94 of file adjlist.hpp.

int AdjList::findFirst ( ) const
inline

Find the first node that has only 1 neighbour

Returns
A node with degree 1

Definition at line 113 of file adjlist.hpp.

int AdjList::findNext ( int  node) const
inline

Find an adjacent node that has not been visited or found yet

Parameters
nodeNode to find unvisited adjacent node for
Returns
Unvisited neighbouring node if larger than 0, -1 if no such node exist

Definition at line 77 of file adjlist.hpp.

bool AdjList::isVisited ( int  node) const
inline

Check if node is visited

Parameters
nodenode to check if visited
Returns
true if node is visited

Definition at line 67 of file adjlist.hpp.

void AdjList::print ( )
inline

Print the adjacency list

Definition at line 145 of file adjlist.hpp.

void AdjList::visit ( int  node)
inline

Mark a node as visited

Parameters
nodeNode to mark as visited

Definition at line 56 of file adjlist.hpp.


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