Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable > Class Template Reference

A Graph. More...

#include <FirstGraph.h>

List of all members.

Classes

struct  first_eq_and_valid
struct  first_not_valid
class  gNode
struct  gNodeTypes
struct  is_edge
struct  is_node
struct  makeGraphNode
struct  with_no_lockable
 If true, do not use abstract locks in graph. More...

Public Types

typedef gNodeGraphNode
 Graph node handle.
typedef EdgeTy edge_type
 Edge data type.
typedef NodeTy node_type
 Node data type.
typedef boost::filter_iterator
< is_edge, typename
gNodeTypes::iterator
edge_iterator
 Edge iterator.
typedef
gNodeTypes::EdgeInfo::reference 
edge_data_reference
 Reference to edge data.
typedef gNodeTypes::reference node_data_reference
 Reference to node data.
typedef
boost::transform_iterator
< makeGraphNode,
boost::filter_iterator
< is_node, typename
NodeListTy::iterator > > 
iterator
 Node iterator.
typedef iterator local_iterator

Public Member Functions

template<typename... Args>
GraphNode createNode (Args &&...args)
 Creates a new node holding the indicated data.
void addNode (const GraphNode &n, Galois::MethodFlag mflag=MethodFlag::ALL)
 Adds a node to the graph.
node_data_reference getData (const GraphNode &n, Galois::MethodFlag mflag=MethodFlag::ALL) const
 Gets the node data for a node.
bool containsNode (const GraphNode &n, Galois::MethodFlag mflag=MethodFlag::ALL) const
 Checks if a node is in the graph.
void removeNode (GraphNode n, Galois::MethodFlag mflag=MethodFlag::ALL)
 Removes a node from the graph along with all its outgoing/incoming edges for undirected graphs or outgoing edges for directed graphs.
void resizeEdges (GraphNode src, size_t size, Galois::MethodFlag mflag=MethodFlag::ALL)
 Resize the edges of the node.
edge_iterator addEdge (GraphNode src, GraphNode dst, Galois::MethodFlag mflag=MethodFlag::ALL)
 Adds an edge to graph, replacing existing value if edge already exists.
template<typename... Args>
edge_iterator addMultiEdge (GraphNode src, GraphNode dst, Galois::MethodFlag mflag, Args &&...args)
 Adds and initializes an edge to graph but does not check for duplicate edges.
void removeEdge (GraphNode src, edge_iterator dst, Galois::MethodFlag mflag=MethodFlag::ALL)
 Removes an edge from the graph.
edge_iterator findEdge (GraphNode src, GraphNode dst, Galois::MethodFlag mflag=MethodFlag::ALL)
 Finds if an edge between src and dst exists.
edge_data_reference getEdgeData (edge_iterator ii, Galois::MethodFlag mflag=MethodFlag::NONE) const
 Returns the edge data associated with the edge.
GraphNode getEdgeDst (edge_iterator ii)
 Returns the destination of an edge.
edge_iterator edge_begin (GraphNode N, Galois::MethodFlag mflag=MethodFlag::ALL)
 Returns an iterator to the neighbors of a node.
edge_iterator edge_end (GraphNode N, Galois::MethodFlag mflag=MethodFlag::ALL)
 Returns the end of the neighbor iterator.
detail::EdgesIterator< FirstGraphout_edges (GraphNode N, MethodFlag mflag=MethodFlag::ALL)
 An object with begin() and end() methods to iterate over the outgoing edges of N.
iterator begin ()
 Returns an iterator to all the nodes in the graph.
iterator end ()
 Returns the end of the node iterator. Not thread-safe.
local_iterator local_begin ()
local_iterator local_end ()
unsigned int size ()
 Returns the number of nodes in the graph.
size_t sizeOfEdgeData () const
 Returns the size of edge data.

Private Types

typedef Galois::InsertBag< gNodeNodeListTy

Private Member Functions

template<typename... Args>
edge_iterator createEdgeWithReuse (GraphNode src, GraphNode dst, Galois::MethodFlag mflag, Args &&...args)
template<typename... Args>
edge_iterator createEdge (GraphNode src, GraphNode dst, Galois::MethodFlag mflag, Args &&...args)

Private Attributes

NodeListTy nodes
FirstGraphImpl::EdgeFactory
< EdgeTy > 
edges

Detailed Description

template<typename NodeTy, typename EdgeTy, bool Directional, bool HasNoLockable = false>
class Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >

A Graph.

An example of use:

 struct Node {
   ... // Definition of node data
 };

 typedef Galois::Graph::FastGraph<Node,int,true> Graph;
 
 // Create graph
 Graph g;
 Node n1, n2;
 Graph::GraphNode a, b;
 a = g.createNode(n1);
 g.addNode(a);
 b = g.createNode(n2);
 g.addNode(b);
 g.getEdgeData(g.addEdge(a, b)) = 5;

 // Traverse graph
 for (Graph::iterator ii = g.begin(), ei = g.end(); ii != ei; ++ii) {
   Graph::GraphNode src = *ii;
   for (Graph::edge_iterator jj = g.edge_begin(src), ej = g.edge_end(src); ++jj) {
     Graph::GraphNode dst = graph.getEdgeDst(jj);
     int edgeData = g.getEdgeData(jj);
     assert(edgeData == 5);
   }
 }

And in C++11:

 // Traverse graph
 for (Graph::GraphNode src : g) {
   for (Graph::edge_iterator edge : g.out_edges(src)) {
     Graph::GraphNode dst = g.getEdgeDst(edge);
     int edgeData = g.getEdgeData(edge);
     assert(edgeData == 5);
   }
 }
Template Parameters:
NodeTy Type of node data
EdgeTy Type of edge data
Directional true if graph is directed

Member Typedef Documentation

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef gNodeTypes::EdgeInfo::reference Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_data_reference

Reference to edge data.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef boost::filter_iterator<is_edge, typename gNodeTypes::iterator> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_iterator

Edge iterator.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef EdgeTy Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_type

Edge data type.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef gNode* Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::GraphNode

Graph node handle.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef boost::transform_iterator<makeGraphNode, boost::filter_iterator<is_node, typename NodeListTy::iterator> > Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::iterator

Node iterator.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::local_iterator
template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef gNodeTypes::reference Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::node_data_reference

Reference to node data.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef NodeTy Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::node_type

Node data type.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
typedef Galois::InsertBag<gNode> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::NodeListTy [private]

Member Function Documentation

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::addEdge ( GraphNode  src,
GraphNode  dst,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Adds an edge to graph, replacing existing value if edge already exists.

Ignore the edge data, let the caller use the returned iterator to set the value if desired. This frees us from dealing with the void edge data problem in this API

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
template<typename... Args>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::addMultiEdge ( GraphNode  src,
GraphNode  dst,
Galois::MethodFlag  mflag,
Args &&...  args 
) [inline]

Adds and initializes an edge to graph but does not check for duplicate edges.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
void Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::addNode ( const GraphNode n,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Adds a node to the graph.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::begin (  )  [inline]

Returns an iterator to all the nodes in the graph.

Not thread-safe.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
bool Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::containsNode ( const GraphNode n,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) const [inline]

Checks if a node is in the graph.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
template<typename... Args>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::createEdge ( GraphNode  src,
GraphNode  dst,
Galois::MethodFlag  mflag,
Args &&...  args 
) [inline, private]
template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
template<typename... Args>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::createEdgeWithReuse ( GraphNode  src,
GraphNode  dst,
Galois::MethodFlag  mflag,
Args &&...  args 
) [inline, private]
template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
template<typename... Args>
GraphNode Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::createNode ( Args &&...  args  )  [inline]

Creates a new node holding the indicated data.

Usually you should call addNode() afterwards.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_begin ( GraphNode  N,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Returns an iterator to the neighbors of a node.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_end ( GraphNode  N,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Returns the end of the neighbor iterator.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::end (  )  [inline]

Returns the end of the node iterator. Not thread-safe.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::findEdge ( GraphNode  src,
GraphNode  dst,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Finds if an edge between src and dst exists.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
node_data_reference Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::getData ( const GraphNode n,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) const [inline]

Gets the node data for a node.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
edge_data_reference Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::getEdgeData ( edge_iterator  ii,
Galois::MethodFlag  mflag = MethodFlag::NONE 
) const [inline]

Returns the edge data associated with the edge.

It is an error to get the edge data for a non-existent edge. It is an error to get edge data for inactive edges. By default, the mflag is Galois::NONE because edge_begin() dominates this call and should perform the appropriate locking.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
GraphNode Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::getEdgeDst ( edge_iterator  ii  )  [inline]

Returns the destination of an edge.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
local_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::local_begin (  )  [inline]
template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
local_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::local_end (  )  [inline]
template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
detail::EdgesIterator<FirstGraph> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::out_edges ( GraphNode  N,
MethodFlag  mflag = MethodFlag::ALL 
) [inline]

An object with begin() and end() methods to iterate over the outgoing edges of N.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
void Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::removeEdge ( GraphNode  src,
edge_iterator  dst,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Removes an edge from the graph.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
void Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::removeNode ( GraphNode  n,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Removes a node from the graph along with all its outgoing/incoming edges for undirected graphs or outgoing edges for directed graphs.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
void Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::resizeEdges ( GraphNode  src,
size_t  size,
Galois::MethodFlag  mflag = MethodFlag::ALL 
) [inline]

Resize the edges of the node.

For best performance, should be done serially.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
unsigned int Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::size (  )  [inline]

Returns the number of nodes in the graph.

Not thread-safe.

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
size_t Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::sizeOfEdgeData (  )  const [inline]

Returns the size of edge data.


Member Data Documentation

template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
FirstGraphImpl::EdgeFactory<EdgeTy> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edges [private]
template<typename NodeTy , typename EdgeTy , bool Directional, bool HasNoLockable = false>
NodeListTy Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::nodes [private]

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

Generated on 2 Nov 2013 for Galois by  doxygen 1.6.1