#include <FirstGraph.h>
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 gNode * | GraphNode |
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< FirstGraph > | out_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< gNode > | NodeListTy |
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 |
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); } }
NodeTy | Type of node data | |
EdgeTy | Type of edge data | |
Directional | true if graph is directed |
typedef gNodeTypes::EdgeInfo::reference Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_data_reference |
Reference to edge data.
typedef boost::filter_iterator<is_edge, typename gNodeTypes::iterator> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_iterator |
Edge iterator.
typedef EdgeTy Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edge_type |
Edge data type.
typedef gNode* Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::GraphNode |
Graph node handle.
typedef boost::transform_iterator<makeGraphNode, boost::filter_iterator<is_node, typename NodeListTy::iterator> > Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::iterator |
Node iterator.
typedef iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::local_iterator |
typedef gNodeTypes::reference Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::node_data_reference |
Reference to node data.
typedef NodeTy Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::node_type |
Node data type.
typedef Galois::InsertBag<gNode> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::NodeListTy [private] |
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
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.
void Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::addNode | ( | const GraphNode & | n, | |
Galois::MethodFlag | mflag = MethodFlag::ALL | |||
) | [inline] |
Adds a node to the graph.
iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::begin | ( | ) | [inline] |
Returns an iterator to all the nodes in the graph.
Not thread-safe.
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.
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::createEdge | ( | GraphNode | src, | |
GraphNode | dst, | |||
Galois::MethodFlag | mflag, | |||
Args &&... | args | |||
) | [inline, private] |
edge_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::createEdgeWithReuse | ( | GraphNode | src, | |
GraphNode | dst, | |||
Galois::MethodFlag | mflag, | |||
Args &&... | args | |||
) | [inline, private] |
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.
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.
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.
iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::end | ( | ) | [inline] |
Returns the end of the node iterator. Not thread-safe.
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.
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.
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.
GraphNode Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::getEdgeDst | ( | edge_iterator | ii | ) | [inline] |
Returns the destination of an edge.
local_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::local_begin | ( | ) | [inline] |
local_iterator Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::local_end | ( | ) | [inline] |
detail::EdgesIterator<FirstGraph> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::out_edges | ( | GraphNode | N, | |
MethodFlag | mflag = MethodFlag::ALL | |||
) | [inline] |
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.
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.
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.
unsigned int Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::size | ( | ) | [inline] |
Returns the number of nodes in the graph.
Not thread-safe.
size_t Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::sizeOfEdgeData | ( | ) | const [inline] |
Returns the size of edge data.
FirstGraphImpl::EdgeFactory<EdgeTy> Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::edges [private] |
NodeListTy Galois::Graph::FirstGraph< NodeTy, EdgeTy, Directional, HasNoLockable >::nodes [private] |