Empirical
Classes | Public Member Functions | Protected Attributes | List of all members
emp::Graph Class Reference

A graph class that maintains a set of vertices (nodes) and edges (connecting pairs of nodes) More...

#include <Graph.h>

Inheritance diagram for emp::Graph:
emp::WeightedGraph

Classes

class  Node
 Information about nodes within a graph. More...
 

Public Member Functions

 Graph (size_t num_nodes=0)
 Construct a new graph with the specified number of nodes. More...
 
 Graph (const Graph &)=default
 Copy constructor. More...
 
 Graph (Graph &&)=default
 Move constructor. More...
 
 ~Graph ()
 
Graphoperator= (const Graph &)=default
 Copy operator. More...
 
Graphoperator= (Graph &&)=default
 Move operator. More...
 
size_t GetSize () const
 Get number of vertices in this graph. More...
 
size_t GetEdgeCount () const
 Get the total number of edges in this graph. More...
 
void Resize (size_t new_size)
 Change the number of vertices in this graph. More...
 
const BitVectorGetEdgeSet (size_t id) const
 Get the set of nodes that a specified node is connected to. More...
 
size_t GetDegree (size_t id) const
 Get the degree of a specified node. More...
 
size_t GetMaskedDegree (size_t id, const BitVector &mask) const
 Get how many of a set of nodes that a specified node is connected to. More...
 
bool HasEdge (size_t from, size_t to) const
 Determine if a specific edge is included in this graph. More...
 
void AddEdge (size_t from, size_t to)
 Add a specified edge into this graph. More...
 
void RemoveEdge (size_t from, size_t to)
 Remove a specified edge from this graph. More...
 
void SetEdge (size_t from, size_t to, bool val)
 Set the status of a specified edge as to whether or not it should be in the graph. More...
 
bool HasEdgePair (size_t from, size_t to) const
 Determine if edges exist in both directions between a pair of vertices. More...
 
void AddEdgePair (size_t from, size_t to)
 Add a pair of edges between two vertieces (in both directions) More...
 
void RemoveEdgePair (size_t from, size_t to)
 Remove edges in both directions between a pair of vertices. More...
 
void SetEdgePairs (size_t from, size_t to, bool val)
 Set the status as to whether a pair of edges (in both direction) exist. More...
 
void Merge (const Graph &in_graph)
 Merge a second graph into this one. More...
 
void PrintSym (std::ostream &os=std::cout)
 Print a symmetric graph to the provided output stream (defaulting to standard out) More...
 
void PrintDirected (std::ostream &os=std::cout)
 Print a directed graph to the provided output stream (defaulting to standard out) More...
 

Protected Attributes

emp::vector< Nodenodes
 Set of vertices in this graph. More...
 

Detailed Description

A graph class that maintains a set of vertices (nodes) and edges (connecting pairs of nodes)

Constructor & Destructor Documentation

emp::Graph::Graph ( size_t  num_nodes = 0)
inline

Construct a new graph with the specified number of nodes.

emp::Graph::Graph ( const Graph )
default

Copy constructor.

emp::Graph::Graph ( Graph &&  )
default

Move constructor.

emp::Graph::~Graph ( )
inline

Member Function Documentation

void emp::Graph::AddEdge ( size_t  from,
size_t  to 
)
inline

Add a specified edge into this graph.

void emp::Graph::AddEdgePair ( size_t  from,
size_t  to 
)
inline

Add a pair of edges between two vertieces (in both directions)

size_t emp::Graph::GetDegree ( size_t  id) const
inline

Get the degree of a specified node.

size_t emp::Graph::GetEdgeCount ( ) const
inline

Get the total number of edges in this graph.

const BitVector& emp::Graph::GetEdgeSet ( size_t  id) const
inline

Get the set of nodes that a specified node is connected to.

size_t emp::Graph::GetMaskedDegree ( size_t  id,
const BitVector mask 
) const
inline

Get how many of a set of nodes that a specified node is connected to.

size_t emp::Graph::GetSize ( ) const
inline

Get number of vertices in this graph.

bool emp::Graph::HasEdge ( size_t  from,
size_t  to 
) const
inline

Determine if a specific edge is included in this graph.

bool emp::Graph::HasEdgePair ( size_t  from,
size_t  to 
) const
inline

Determine if edges exist in both directions between a pair of vertices.

void emp::Graph::Merge ( const Graph in_graph)
inline

Merge a second graph into this one.

Graph& emp::Graph::operator= ( const Graph )
default

Copy operator.

Graph& emp::Graph::operator= ( Graph &&  )
default

Move operator.

void emp::Graph::PrintDirected ( std::ostream &  os = std::cout)
inline

Print a directed graph to the provided output stream (defaulting to standard out)

void emp::Graph::PrintSym ( std::ostream &  os = std::cout)
inline

Print a symmetric graph to the provided output stream (defaulting to standard out)

void emp::Graph::RemoveEdge ( size_t  from,
size_t  to 
)
inline

Remove a specified edge from this graph.

void emp::Graph::RemoveEdgePair ( size_t  from,
size_t  to 
)
inline

Remove edges in both directions between a pair of vertices.

void emp::Graph::Resize ( size_t  new_size)
inline

Change the number of vertices in this graph.

void emp::Graph::SetEdge ( size_t  from,
size_t  to,
bool  val 
)
inline

Set the status of a specified edge as to whether or not it should be in the graph.

void emp::Graph::SetEdgePairs ( size_t  from,
size_t  to,
bool  val 
)
inline

Set the status as to whether a pair of edges (in both direction) exist.

Member Data Documentation

emp::vector<Node> emp::Graph::nodes
protected

Set of vertices in this graph.


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