Rosetta
2021.07

A Digraph with constant time edge insertion and deletion. Extensible. More...
#include <Digraph.hh>
Public Member Functions  
DigraphCOP  get_self_ptr () const 
self pointers More...  
DigraphOP  get_self_ptr () 
~Digraph () override  
virtual destructor. Derived classes must ensure they've destroyed all their nodes and edges through a call to "destroy_everything" before this function is arrived at More...  
Digraph ()  
ctor More...  
Digraph (platform::Size num_nodes)  
num nodes ctor More...  
Digraph (Digraph const &source)  
copy ctor. Must not be called by derived class copy ctors. More...  
Digraph &  operator= (Digraph const &source) 
assignment operator. source and this must have the same type. More...  
void  copy_connectivity (Digraph const &source) 
copy the edge connectivity from a source graph with a potentially unknown type. More...  
platform::Size  num_nodes () const 
the number of nodes in the graph More...  
void  set_num_nodes (platform::Size num_nodes) 
set the number of nodes in the graph – deletes any existing edges in the graph More...  
void  add_node () 
Add a new node to the graph; preserve all of the existing edges in the graph. More...  
DirectedEdge *  add_edge (platform::Size tail_node, platform::Size head_node) 
add a directed edge between two vertices. Invokes "create_edge" from the derived class. Returns a pointer to the edge after its been added, allowing the calling function to immediately set data for this edge. More...  
DirectedEdge *  add_edge (DirectedEdge const *example_edge) 
add an edge to this graph copying the data from an edge in another graph. Returns a pointer to the edge after its been added, allowing the calling function to immediately set data for this edge. More...  
bool  get_edge_exists (platform::Size tail_node, platform::Size head_node) const 
is an edge already present in the graph? O(V) worst case. O(1) iff all vertices have O(1) edges More...  
void  drop_all_edges () 
delete all the edges present in the graph More...  
void  drop_all_edges_for_node (platform::Size node) 
delete all the edges for a single vertex in the graph More...  
void  print_vertices () const 
send summary information to the screen for all vertices in the graph More...  
void  output_connectivity (std::ostream &os) const 
send an edge list to the stream os. More...  
void  output_dimacs (std::ostream &os) const 
describe this graph in dimacs form to the stream os. More...  
DirectedNode const *  get_node (platform::Size index) const 
DirectedNode *  get_node (platform::Size index) 
platform::Size  num_edges () const 
DirectedEdgeListConstIter  const_edge_list_begin () const 
returns a const iterator to the beginning of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex More...  
DirectedEdgeListIter  edge_list_begin () 
returns a nonconst iterator to the beginning of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex More...  
DirectedEdgeListConstIter  const_edge_list_end () const 
returns a const iterator to the end of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex More...  
DirectedEdgeListIter  edge_list_end () 
returns a nonconst iterator to the end of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex More...  
DirectedEdge *  find_edge (platform::Size tail_node, platform::Size head_node) 
returns a pointer to the directed edge connecting nodes tail_node and head_node, if that edge exists in the graph, o.w. returns 0. Focuses the graph on this edge for fast subsequent retrieval. More...  
DirectedEdge const *  find_edge (platform::Size tail_node, platform::Size head_node) const 
returns a const pointer to the directed edge connecting nodes tail_node and head_node, if that edge exists in the graph, o.w. returns 0. Focuses the graph on this edge for fast subsequent retrieval. More...  
DirectedEdge *  focused_edge () 
returns a pointer to the focused edge More...  
DirectedEdge const *  focused_edge () const 
returns a constpointer to the focused edge More...  
virtual void  delete_edge (DirectedEdge *edge) 
remove an edge from the graph. (NEW AS OF 12/9/07) Never call C++'s "delete" function on an edge pointer directly. Derived classes must implement this function. If they wish to use unordered_object_pools to manage their memory More...  
platform::Size  getTotalMemoryUsage () const 
returns a count of all the memory used by every vertex and edge in a graph by invoking the polymorphic count_static_memory and count_dynamic_memory of each (possibly derived) node and edge object as well as for the (possibly derived) graph class. More...  
Public Member Functions inherited from utility::VirtualBase  
VirtualBase ()=default  
Default constructor. More...  
virtual  ~VirtualBase ()=default 
The virtual destructor is one of the main reasons for the VirtualBase class. More...  
VirtualBase (VirtualBase const &)=default  
VirtualBase (VirtualBase &&)=default  
VirtualBase &  operator= (VirtualBase const &)=default 
VirtualBase &  operator= (VirtualBase &&)=default 
Protected Member Functions  
virtual platform::Size  count_static_memory () const 
virtual platform::Size  count_dynamic_memory () const 
void  drop_edge (DirectedEdgeListIter edge_iter) 
remove an edge from the entiregraph edge list. Called only by class DirectedEdge during its destructor More...  
void  delete_everything () 
deallocate all nodes and edges from the graph More...  
virtual DirectedNode *  create_new_node (platform::Size node_index) 
factory method for node creation, defined by derived graph classes, called by the base class More...  
virtual DirectedEdge *  create_new_edge (platform::Size index1, platform::Size index2) 
factory method for edge creation, defined by derived graph classes, called by the base class More...  
virtual DirectedEdge *  create_new_edge (DirectedEdge const *example_edge) 
factory method for edge copyconstruction. Derived class should downcast the example_edge pointer and may read that edge's data. More...  
boost::unordered_object_pool < DirectedEdgeListElement > &  edge_list_element_pool () 
Used by class DirectedNode only, this is the pool from which edge lists are to allocate their edge lists elements from. More...  
Private Attributes  
platform::Size  num_nodes_ 
DirectedNodeVector  nodes_ 
platform::Size  num_edges_ 
boost::unordered_object_pool < DirectedEdgeListElement > *  edge_list_element_pool_ 
the pool from which edge lists are to allocate their edge list elements More...  
DirectedEdgeList  edge_list_ 
boost::unordered_object_pool < DirectedEdge > *  edge_pool_ 
the pool from which class Digraph allocates DirectedEdge objects. Not used by derived classes More...  
DirectedEdge *  focused_edge_ 
Quickaccess to a frequently needed edge – the most recently sought edge in a call to find_edge() or the most recently added edge. More...  
Friends  
class  DirectedNode 
class  DirectedEdge 

override 
virtual destructor. Derived classes must ensure they've destroyed all their nodes and edges through a call to "destroy_everything" before this function is arrived at
destructor
References delete_everything(), edge_list_element_pool_, and edge_pool_.
utility::graph::Digraph::Digraph  (  ) 
ctor
default constructor; creates an empty graph (no nodes, no edges)
Referenced by count_static_memory().
utility::graph::Digraph::Digraph  (  platform::Size  num_nodes  ) 
num nodes ctor
Do not call this constructor from a derived class in the initialization list, since this constructor calls the polymorphic function create_new_node, and polymorphism does not work during constructors or destructors.
num_ig_nodes   [in]  number of nodes that this graph will contain 
References create_new_node(), test.T200_Scoring::ii, nodes_, and num_nodes().
utility::graph::Digraph::Digraph  (  Digraph const &  source  ) 
copy ctor. Must not be called by derived class copy ctors.
copy constructor relies on factory methods and virtual "copy_from" methods
This copy constructor should NOT be used by derived classes. At the time this is called, the identity of this has not yet been resolved – this constructor will produce DirectedNode and DirectedEdge objects when it calls "create_new_node" and not DerivedDirectedNode or DerivedDirectedEdge objects. Derived class copy constructors should call the base class assignment operator once the initial construction has been completed.
References add_edge(), const_edge_list_begin(), const_edge_list_end(), utility::graph::DirectedEdge::copy_from(), create_new_node(), find_edge(), test.T200_Scoring::ii, nodes_, and num_nodes_.
DirectedEdge * utility::graph::Digraph::add_edge  (  platform::Size  tail_index, 
platform::Size  head_index  
) 
add a directed edge between two vertices. Invokes "create_edge" from the derived class. Returns a pointer to the edge after its been added, allowing the calling function to immediately set data for this edge.
creates a new edge between nodes tail_index and head_index. DirectedNodes do not have to be listed in order. For speed, does NOT check to see if edge already exists – except in debug mode.
uses factory method create_new_edge and adds the created edge to the graph's edge list. Not threadsafe. Only a single thread should add edges to the graph at a time.
tail_index   [in]  index of one of the two nodes the edge is to connect 
head_index   [in]  index of the second of the two nodes the edge is to connect 
References create_new_edge(), debug_assert, edge_list_, focused_edge_, get_edge_exists(), utility::graph::DirectedEdgeList::last(), num_edges_, utility::graph::DirectedEdgeList::push_back(), and utility::graph::DirectedEdge::set_pos_in_owners_list().
Referenced by copy_connectivity(), Digraph(), and operator=().
DirectedEdge * utility::graph::Digraph::add_edge  (  DirectedEdge const *  example_edge  ) 
add an edge to this graph copying the data from an edge in another graph. Returns a pointer to the edge after its been added, allowing the calling function to immediately set data for this edge.
for use in Digraph operator=
Uses the edge copy constructor so that data stored on edges of one graph may be placed rapidly into the new edge of this graph.
References utility::graph::DirectedEdgeList::begin(), create_new_edge(), debug_assert, edge_list_, focused_edge_, get_edge_exists(), utility::graph::DirectedEdge::get_head_node_ind(), utility::graph::DirectedEdge::get_tail_node_ind(), num_edges_, utility::graph::DirectedEdgeList::push_front(), and utility::graph::DirectedEdge::set_pos_in_owners_list().
void utility::graph::Digraph::add_node  (  ) 
Add a new node to the graph; preserve all of the existing edges in the graph.
References create_new_node(), nodes_, and num_nodes_.

inline 
returns a const iterator to the beginning of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex
References utility::graph::DirectedEdgeList::const_begin(), and edge_list_.
Referenced by copy_connectivity(), Digraph(), and operator=().

inline 
returns a const iterator to the end of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex
References utility::graph::DirectedEdgeList::const_end(), and edge_list_.
Referenced by copy_connectivity(), Digraph(), and operator=().
void utility::graph::Digraph::copy_connectivity  (  Digraph const &  source  ) 
copy the edge connectivity from a source graph with a potentially unknown type.
copy the connectivity of the source graph, but do not copy the data stored in the nodes and edges of the source graph. Useful for when copying a graph of a different type (e.g. from an EnergyDigraph into a Digraph)
References add_edge(), const_edge_list_begin(), const_edge_list_end(), drop_all_edges(), num_nodes_, and set_num_nodes().

protectedvirtual 
References num_edges_, and num_nodes_.
Referenced by getTotalMemoryUsage().

protectedvirtual 
References Digraph().
Referenced by getTotalMemoryUsage().

protectedvirtual 
factory method for edge creation, defined by derived graph classes, called by the base class
factory method for edge creation Should be overriden in derived classes
References edge_pool_.
Referenced by add_edge().

protectedvirtual 
factory method for edge copyconstruction. Derived class should downcast the example_edge pointer and may read that edge's data.
References edge_pool_, utility::graph::DirectedEdge::get_head_node_ind(), and utility::graph::DirectedEdge::get_tail_node_ind().

protectedvirtual 
factory method for node creation, defined by derived graph classes, called by the base class
factory method for node creation Should be overriden in derived classes
References DirectedNode.
Referenced by add_node(), Digraph(), and set_num_nodes().

virtual 
remove an edge from the graph. (NEW AS OF 12/9/07) Never call C++'s "delete" function on an edge pointer directly. Derived classes must implement this function. If they wish to use unordered_object_pools to manage their memory
References edge_pool_.
Referenced by delete_everything(), utility::graph::DirectedNode::drop_all_edges(), and drop_all_edges().

protected 
deallocate all nodes and edges from the graph
deletes each edge in the graph and then deletes each node
its important to note that nodes must outlive their incident edges
References utility::graph::DirectedEdgeList::begin(), delete_edge(), edge_list_, utility::graph::DirectedEdgeList::end(), focused_edge_, test.T200_Scoring::ii, nodes_, and num_nodes_.
Referenced by set_num_nodes(), and ~Digraph().
void utility::graph::Digraph::drop_all_edges  (  ) 
delete all the edges present in the graph
deletes all edges in the graph
References utility::graph::DirectedEdgeList::begin(), delete_edge(), edge_list_, and utility::graph::DirectedEdgeList::end().
Referenced by copy_connectivity(), and operator=().
void utility::graph::Digraph::drop_all_edges_for_node  (  platform::Size  node  ) 
delete all the edges for a single vertex in the graph
deletes all edges adjacent to the node specified
node   [in]  index of the node 
References utility::graph::DirectedNode::drop_all_edges(), and get_node().

protected 
remove an edge from the entiregraph edge list. Called only by class DirectedEdge during its destructor
removes edge from edge list at iterator iter
each edge keeps track of its position in its owner's graph's edge list so it can efficiently delete itself should it need to.
iter   [in]  the iterator in the nonconst edge list pointing at the edge that's deleting itself 
citer   [in]  the iterator in the const edge list pointing at the edge that's deleting itself 
References edge_list_, utility::graph::DirectedEdgeList::erase(), focused_edge_, and num_edges_.
Referenced by utility::graph::DirectedEdge::~DirectedEdge().

inline 
returns a nonconst iterator to the beginning of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex
References utility::graph::DirectedEdgeList::begin(), and edge_list_.

inlineprotected 
Used by class DirectedNode only, this is the pool from which edge lists are to allocate their edge lists elements from.
References edge_list_element_pool_.

inline 
returns a nonconst iterator to the end of the (unordered) edge list for the graph. this edge list contains all the edges in the graph, not simply those for a particular vertex
References edge_list_, and utility::graph::DirectedEdgeList::end().
DirectedEdge * utility::graph::Digraph::find_edge  (  platform::Size  tail_node, 
platform::Size  head_node  
) 
returns a pointer to the directed edge connecting nodes tail_node and head_node, if that edge exists in the graph, o.w. returns 0. Focuses the graph on this edge for fast subsequent retrieval.
returns the edge connecting tail_node and head_node
graph keeps a pointer to the last edge that was accessed to that search is fairly efficient.
tail_node   [in]  index of the first node 
head_node   [in]  index of the second node 
References focused_edge_, nodes_, and utility::graph::DirectedEdge::same_edge().
Referenced by Digraph(), and get_edge_exists().
DirectedEdge const * utility::graph::Digraph::find_edge  (  platform::Size  tail_node, 
platform::Size  head_node  
)  const 
returns a const pointer to the directed edge connecting nodes tail_node and head_node, if that edge exists in the graph, o.w. returns 0. Focuses the graph on this edge for fast subsequent retrieval.
returns the edge connecting tail_node and head_node (const version)
graph keeps a pointer to the last edge that was accessed to that search is fairly efficient.
tail_node   [in]  index of the tail node 
head_node   [in]  index of the head node 
References focused_edge_, nodes_, and utility::graph::DirectedEdge::same_edge().

inline 
returns a pointer to the focused edge
References focused_edge_.

inline 
returns a constpointer to the focused edge
References focused_edge_.
bool utility::graph::Digraph::get_edge_exists  (  platform::Size  tail_node, 
platform::Size  head_node  
)  const 
is an edge already present in the graph? O(V) worst case. O(1) iff all vertices have O(1) edges
returns true if an edge between tail_node and head_node exists
tail_node   [in]  index of the one of the nodes 
head_node   [in]  index of the other node 
References find_edge().
Referenced by add_edge().

inline 
References debug_assert, ObjexxFCL::index(), nodes_, and num_nodes_.
Referenced by drop_all_edges_for_node(), and utility::graph::visit().

inline 
References debug_assert, ObjexxFCL::index(), nodes_, and num_nodes_.

inline 
self pointers

inline 
platform::Size utility::graph::Digraph::getTotalMemoryUsage  (  )  const 
returns a count of all the memory used by every vertex and edge in a graph by invoking the polymorphic count_static_memory and count_dynamic_memory of each (possibly derived) node and edge object as well as for the (possibly derived) graph class.
References utility::graph::DirectedEdgeList::const_begin(), utility::graph::DirectedEdgeList::const_end(), count_dynamic_memory(), count_static_memory(), edge_list_, test.T200_Scoring::ii, nodes_, and num_nodes().

inline 
References num_edges_.
Referenced by output_dimacs().

inline 
the number of nodes in the graph
References num_nodes_.
Referenced by Digraph(), getTotalMemoryUsage(), set_num_nodes(), and utility::graph::topological_sort().
assignment operator. source and this must have the same type.
operator = (). Relies on factory methods and virtual "copy_from" methods
operator= must only be performed on graphs of the same type e.g. an EnergyDigraph may be copied from another EnergyDigraph, but should not be copied from a Digraph.
References add_edge(), const_edge_list_begin(), const_edge_list_end(), drop_all_edges(), test.T200_Scoring::ii, nodes_, num_nodes_, and set_num_nodes().
void utility::graph::Digraph::output_connectivity  (  std::ostream &  os  )  const 
send an edge list to the stream os.
writes out a list of all the edges in the graph
os   [in]  the output stream to write to 
References utility::graph::DirectedEdgeList::begin(), demo.D060_Folding::counter, edge_list_, and utility::graph::DirectedEdgeList::end().
void utility::graph::Digraph::output_dimacs  (  std::ostream &  os  )  const 
describe this graph in dimacs form to the stream os.
writes out a connectivity description of the graph in the famous dimacs format. (where the first column "DIMACS:" should be sed'ed out)
os   [in]  the output stream to write to 
References utility::graph::DirectedEdgeList::begin(), edge_list_, utility::graph::DirectedEdgeList::end(), num_edges(), num_nodes_, and utility::graph::DirectedEdgeList::size().
void utility::graph::Digraph::print_vertices  (  )  const 
send summary information to the screen for all vertices in the graph
calls print() on each of the nodes in the graph
References test.T200_Scoring::ii, nodes_, and num_nodes_.
void utility::graph::Digraph::set_num_nodes  (  platform::Size  num_nodes  ) 
set the number of nodes in the graph – deletes any existing edges in the graph
alternative to integer constructor; first create an empty graph and later tell the graph how many nodes it has. If the graph is not already empty, it will delete everything its holding.
References create_new_node(), delete_everything(), test.T200_Scoring::ii, nodes_, num_nodes(), and num_nodes_.
Referenced by copy_connectivity(), and operator=().

friend 

friend 
Referenced by create_new_node().

private 

private 
the pool from which edge lists are to allocate their edge list elements
Referenced by edge_list_element_pool(), and ~Digraph().

private 
the pool from which class Digraph allocates DirectedEdge objects. Not used by derived classes
Referenced by create_new_edge(), delete_edge(), and ~Digraph().

mutableprivate 
Quickaccess to a frequently needed edge – the most recently sought edge in a call to find_edge() or the most recently added edge.
Referenced by add_edge(), delete_everything(), drop_edge(), find_edge(), and focused_edge().

private 

private 
Referenced by add_edge(), count_dynamic_memory(), drop_edge(), and num_edges().

private 