AvogadroLibs  1.90.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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 ( )

Creates a new, empty graph.

Graph ( size_t  n)
explicit

Creates a new graph containing size n vertices.

~Graph ( )

Destroys the graph.

Member Function Documentation

void setSize ( size_t  n)

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

size_t size ( ) const

Returns the number of verticies in the graph.

bool isEmpty ( ) const

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

void clear ( )

Removes all verticies and edges from the graph.

size_t addVertex ( )

Adds a vertex to the graph and returns its index.

void removeVertex ( size_t  index)

Removes the vertex at index from the graph.

size_t vertexCount ( ) const

Returns the number of verticies in the graph.

void addEdge ( size_t  a,
size_t  b 
)

Adds an edge between verticies a and b.

void removeEdge ( size_t  a,
size_t  b 
)

Removes the edge between veritices a and b.

void removeEdges ( )

Removes all of the edges from the graph.

void removeEdges ( size_t  index)

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

size_t edgeCount ( ) const

Returns the number of edges in the graph.

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.

size_t degree ( size_t  index) const

Returns the degree of the vertex at index.

bool containsEdge ( size_t  a,
size_t  b 
) const

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

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: