Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Types | Public Member Functions
nom::Graph< T, U > Class Template Reference

A simple graph implementation. More...

#include <Graph.h>

Public Types

using NodeRef = Node< T, U > *
 
using EdgeRef = Edge< T, U > *
 
using NodeType = T
 
using EdgeType = U
 

Public Member Functions

 Graph (const Graph &)=delete
 
 Graph (Graph &&)=default
 
Graphoperator= (Graph &&)=default
 
NodeRef createNode (T &&data)
 Creates a node and retains ownership of it. More...
 
void swapNode (NodeRef node, Graph< T, U > &otherGraph)
 
void swapEdge (EdgeRef edge, Graph< T, U > &otherGraph)
 
NodeRef createNode ()
 
void replaceNode (const NodeRef &old, const NodeRef &newTail, const NodeRef &newHead_=nullptr)
 Replace a node in the graph with a generic set of nodes. More...
 
EdgeRef createEdge (NodeRef tail, NodeRef head)
 Creates a directed edge and retains ownership of it. More...
 
EdgeRef createEdge (NodeRef tail, NodeRef head, U &&data)
 
EdgeRef getEdge (NodeRef tail, NodeRef head)
 Get a reference to the edge between two nodes if it exists. More...
 
void deleteNode (NodeRef n, bool deleteEdges=true)
 Deletes a node from the graph. More...
 
void deleteEdge (EdgeRef e)
 Deletes a edge from the graph. More...
 
const std::vector< NodeRefgetMutableNodes ()
 
const std::vector< EdgeRefgetMutableEdges ()
 
void printEdges ()
 
void printNodes () const
 

Detailed Description

template<typename T, typename U>
class nom::Graph< T, U >

A simple graph implementation.

Everything is owned by the graph to simplify storage concerns.

Definition at line 30 of file Graph.h.

Member Function Documentation

template<typename T, typename U>
EdgeRef nom::Graph< T, U >::createEdge ( NodeRef  tail,
NodeRef  head 
)
inline

Creates a directed edge and retains ownership of it.

tail The node that will have this edge as an out-edge. head The node that will have this edge as an in-edge.

Returns
A reference to the edge created.

Definition at line 230 of file Graph.h.

template<typename T, typename U>
NodeRef nom::Graph< T, U >::createNode ( T &&  data)
inline

Creates a node and retains ownership of it.

data An rvalue of the data being held in the node.

Returns
A reference to the node created.

Definition at line 164 of file Graph.h.

template<typename T, typename U>
void nom::Graph< T, U >::deleteEdge ( EdgeRef  e)
inline

Deletes a edge from the graph.

e A reference to the edge.

Definition at line 283 of file Graph.h.

template<typename T, typename U>
void nom::Graph< T, U >::deleteNode ( NodeRef  n,
bool  deleteEdges = true 
)
inline

Deletes a node from the graph.

Parameters
nA reference to the node.
deleteEdges(optional) Whether or not to delete the edges related to the node.

Definition at line 264 of file Graph.h.

template<typename T, typename U>
EdgeRef nom::Graph< T, U >::getEdge ( NodeRef  tail,
NodeRef  head 
)
inline

Get a reference to the edge between two nodes if it exists.

note: will fail assertion if the edge does not exist.

Definition at line 250 of file Graph.h.

template<typename T, typename U>
void nom::Graph< T, U >::replaceNode ( const NodeRef old,
const NodeRef newTail,
const NodeRef newHead_ = nullptr 
)
inline

Replace a node in the graph with a generic set of nodes.

Note
The node replaced simply has its edges cut, but it not deleted from the graph. Call Graph::deleteNode to delete it. old A node to be replaced in the graph. newTail The node that inherit the old node's in-edges newHead (optional) The node that inherit the old node's out-edges

Definition at line 203 of file Graph.h.


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