AvogadroLibs  1.90.0
Public Member Functions | List of all members
Graph Class Reference

The Graph class represents a graph data structure.

#include <avogadro/core/graph.h>

Public Member Functions

 Graph ()
 
 Graph (size_t n)
 
 ~Graph ()
 
void setSize (size_t n)
 
size_t size () const
 
bool isEmpty () const
 
void clear ()
 
size_t addVertex ()
 
void removeVertex (size_t index)
 
size_t vertexCount () const
 
void addEdge (size_t a, size_t b)
 
void removeEdge (size_t a, size_t b)
 
void removeEdges ()
 
void removeEdges (size_t index)
 
size_t edgeCount () const
 
const std::vector< size_t > & neighbors (size_t index) const
 
size_t degree (size_t index) const
 
bool containsEdge (size_t a, size_t b) const
 
std::vector< std::vector< size_t > > connectedComponents () const
 

Constructor & Destructor Documentation

◆ Graph() [1/2]

Graph ( )

Creates a new, empty graph.

◆ Graph() [2/2]

Graph ( size_t  n)
explicit

Creates a new graph containing size n vertices.

◆ ~Graph()

~Graph ( )

Destroys the graph.

Member Function Documentation

◆ setSize()

void setSize ( size_t  n)

Sets the number of verticies in the graph to size n.

◆ size()

size_t size ( ) const

Returns the number of verticies in the graph.

◆ isEmpty()

bool isEmpty ( ) const

Returns true if the graph is empty (i.e. size() == 0).

◆ clear()

void clear ( )

Removes all verticies and edges from the graph.

◆ addVertex()

size_t addVertex ( )

Adds a vertex to the graph and returns its index.

◆ removeVertex()

void removeVertex ( size_t  index)

Removes the vertex at index from the graph.

◆ vertexCount()

size_t vertexCount ( ) const

Returns the number of verticies in the graph.

◆ addEdge()

void addEdge ( size_t  a,
size_t  b 
)

Adds an edge between verticies a and b.

◆ removeEdge()

void removeEdge ( size_t  a,
size_t  b 
)

Removes the edge between veritices a and b.

◆ removeEdges() [1/2]

void removeEdges ( )

Removes all of the edges from the graph.

◆ removeEdges() [2/2]

void removeEdges ( size_t  index)

Removes all of the edges that contain the vertex at index from the graph.

◆ edgeCount()

size_t edgeCount ( ) const

Returns the number of edges in the graph.

◆ neighbors()

const std::vector<size_t>& neighbors ( size_t  index) const

Returns a vector containing the indicies of each vertex that the vertex at index shares an edge with.

◆ degree()

size_t degree ( size_t  index) const

Returns the degree of the vertex at index.

◆ containsEdge()

bool containsEdge ( size_t  a,
size_t  b 
) const

Returns true if the graph contains an edge between verticies a and b.

◆ connectedComponents()

std::vector<std::vector<size_t> > connectedComponents ( ) const

Returns a vector of vector containing the indicies of each vertex in each connected component in the graph.


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