ModErn Text Analysis
META Enumerates Textual Applications
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
meta::graph::undirected_graph< Node, Edge > Class Template Reference

A simple class to represent a directed graph in memory. More...

#include <undirected_graph.h>

Inheritance diagram for meta::graph::undirected_graph< Node, Edge >:
meta::graph::graph< Node, Edge >

Classes

class  directed_graph
 
class  edge_iterator
 
class  node_iterator
 

Public Types

using adjacency_list = typename graph< Node, Edge >::adjacency_list
 
using vec_t = std::vector< std::pair< Node, adjacency_list >>
 
typedef node_iterator< typename vec_t::iterator > iterator
 
typedef node_iterator< typename vec_t::const_iterator > const_iterator
 
typedef edge_iterator< typename vec_t::iterator > e_iterator
 
typedef edge_iterator< typename vec_t::const_iterator > const_e_iterator
 
- Public Types inherited from meta::graph::graph< Node, Edge >
using adjacency_list = std::vector< std::pair< node_id, Edge >>
 

Public Member Functions

const adjacency_list & adjacent (node_id id) const
 
virtual node_id insert (Node node) override
 
virtual void add_edge (Edge edge, node_id source, node_id dest) override
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
e_iterator edges_begin ()
 
const_e_iterator edges_begin () const
 
e_iterator edges_end ()
 
const_e_iterator edges_end () const
 
- Public Member Functions inherited from meta::graph::graph< Node, Edge >
virtual Node & node (node_id id)
 
virtual const Node & node (node_id id) const
 
virtual util::optional< Edge > edge (node_id source, node_id dest) const
 
virtual uint64_t size () const
 
virtual uint64_t num_edges () const
 
template<class... Args>
node_id emplace (Args &&...args)
 Constructs a node with forwarded arguments. More...
 
virtual void add_edge (node_id source, node_id dest)
 Adds a default edge between the two nodes. More...
 

Static Public Member Functions

static undirected_graph< Node, Edge > load (const std::string &filename, bool display_errors=false)
 

Additional Inherited Members

- Protected Attributes inherited from meta::graph::graph< Node, Edge >
std::vector< std::pair< Node, adjacency_list > > nodes_
 Each Node object is indexed by its id.
 
uint64_t num_edges_ = 0
 Saves the number of edges in this graph.
 

Detailed Description

template<class Node = default_node, class Edge = default_edge>
class meta::graph::undirected_graph< Node, Edge >

A simple class to represent a directed graph in memory.

Member Function Documentation

template<class Node , class Edge >
auto undirected_graph< Node, Edge >::adjacent ( node_id  id) const
Parameters
idThe node id to get adjacent nodes to
Returns
the connected edges and node_ids to the given node
template<class Node , class Edge >
node_id undirected_graph< Node, Edge >::insert ( Node  node)
overridevirtual
Parameters
nodeThe new object to add into the graph
Returns
the id of the inserted node

Implements meta::graph::graph< Node, Edge >.

template<class Node , class Edge >
void undirected_graph< Node, Edge >::add_edge ( Edge  edge,
node_id  source,
node_id  dest 
)
overridevirtual
Parameters
edge
source
dest

Implements meta::graph::graph< Node, Edge >.

template<class Node = default_node, class Edge = default_edge>
iterator meta::graph::undirected_graph< Node, Edge >::begin ( )
inline
Returns
an iterator to the beginning ("first" node) of this graph
template<class Node = default_node, class Edge = default_edge>
iterator meta::graph::undirected_graph< Node, Edge >::end ( )
inline
Returns
an iterator that represents one past the last node of this graph
template<class Node = default_node, class Edge = default_edge>
e_iterator meta::graph::undirected_graph< Node, Edge >::edges_begin ( )
inline
Returns
an iterator to the beginning ("first" edge) of this graph
template<class Node = default_node, class Edge = default_edge>
e_iterator meta::graph::undirected_graph< Node, Edge >::edges_end ( )
inline
Returns
an iterator that represents one past the last node of this graph
template<class Node , class Edge >
undirected_graph< Node, Edge > undirected_graph< Node, Edge >::load ( const std::string &  filename,
bool  display_errors = false 
)
static
Parameters
filenameThe file that contains a list of edges in the form "v1 v2"
display_errorsWhether to display errors found in the file
Returns
the newly-created graph

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