NGen
Loading...
Searching...
No Matches
network::Network Class Reference

A lightweight, graph based index of hydrologic features. More...

#include <network.hpp>

+ Collaboration diagram for network::Network:

Public Member Functions

 Network ()
 Construct a new empty Network object.
 
 Network (geojson::GeoJSON fabric)
 Construct a new Network object from the features in fabric, assumes features have already been linked.
 
 Network (geojson::GeoJSON features, std::string *link_key)
 Construct a new Network object from features in fabric, creating edges between feature properties defined by link_key.
 
virtual ~Network ()
 Destroy the Network object.
 
NetworkIndexT::const_reverse_iterator begin ()
 Iterator to the first graph vertex descriptor of the topologically ordered graph vertices.
 
NetworkIndexT::const_reverse_iterator end ()
 Iterator to the end of the topologically ordered graph vertices.
 
auto filter (std::string type, SortOrder order=SortOrder::Topological)
 Provides a boost transform_iterator, filtered by type , to the topologically ordered graph vertex string id's.
 
auto filter (std::string type, int target_layer, SortOrder order=SortOrder::Topological)
 Provides a boost transform_iterator, filtered by type , to the topologically ordered graph vertex string id's.
 
std::string get_id (Graph::vertex_descriptor idx)
 Get the string id of a given graph vertex_descriptor idx.
 
std::vector< std::string > get_origination_ids (const std::string &id)
 Get the origination (upstream) ids (immediate neighbors) of all vertices with an edge connecting to id.
 
std::vector< std::string > get_destination_ids (const std::string &id)
 Get the destination (downstream) ids (immediate neighbors) of all vertices with an edge from id.
 
std::size_t size ()
 The number of features in the network (number of vertices)
 
IndexPair headwaters ()
 An iterator pair (begin, end) of the network headwater features.
 
IndexPair tailwaters ()
 An iterator pair (begin, end) of the network tailwater features.
 
void print_network ()
 Print a graphviz (text) representation of the network.
 

Private Member Functions

void init_indicies ()
 Initializes the head/tailwater iterators after the underlying graph is constructed.
 
const NetworkIndexTget_sorted_index (SortOrder order=SortOrder::Topological, bool cache=true)
 Get an index of the graph in a particular order.
 

Private Attributes

NetworkIndexT topo_order
 Vector of topologically sorted features.
 
NetworkIndexT tdfp_order
 
NetworkIndexT headwaters_idx
 Vector of headwater features.
 
NetworkIndexT tailwaters_idx
 Vector of tailwater features.
 
Graph graph
 The underlying boost::Graph.
 
std::unordered_map< std::string, Graph::vertex_descriptor > descriptor_map
 Mapping of identity to graph vertex descriptor.
 
std::unordered_map< std::string, long > layer_map
 Mapping of identifier to hydrofabric layer.
 

Detailed Description

A lightweight, graph based index of hydrologic features.

This class provides various iterators and access to hydrologic feature identities based on their topological relationships. It uses a boost::graph to model the relationship of features, and various iterators of the features based on traversal of this graph.

Constructor & Destructor Documentation

◆ Network() [1/3]

network::Network::Network ( )
inline

Construct a new empty Network object.

◆ Network() [2/3]

Network::Network ( geojson::GeoJSON fabric)

Construct a new Network object from the features in fabric, assumes features have already been linked.

Parameters
fabrica geojson::GeoJSON collection of features to add as nodes to the graph

References network::DEFAULT_LAYER_ID, descriptor_map, graph, init_indicies(), and layer_map.

◆ Network() [3/3]

Network::Network ( geojson::GeoJSON features,
std::string * link_key )

Construct a new Network object from features in fabric, creating edges between feature properties defined by link_key.

Parameters
featuresa geojson::GeoJSON collection of features to add as nodes to the graph
link_keythe property to read from features to determine edge linking, i.e. 'toid'

References descriptor_map, graph, and init_indicies().

◆ ~Network()

virtual network::Network::~Network ( )
inlinevirtual

Destroy the Network object.

Member Function Documentation

◆ begin()

NetworkIndexT::const_reverse_iterator Network::begin ( )

Iterator to the first graph vertex descriptor of the topologically ordered graph vertices.

Returns
NetworkIndexT::const_reverse_iterator

References topo_order.

Referenced by get_destination_ids(), get_origination_ids(), and init_indicies().

◆ end()

NetworkIndexT::const_reverse_iterator Network::end ( )

Iterator to the end of the topologically ordered graph vertices.

Returns
NetworkIndexT::const_reverse_iterator

References topo_order.

Referenced by get_destination_ids(), get_origination_ids(), and init_indicies().

◆ filter() [1/2]

auto network::Network::filter ( std::string type,
int target_layer,
SortOrder order = SortOrder::Topological )
inline

Provides a boost transform_iterator, filtered by type , to the topologically ordered graph vertex string id's.

This function is useful when only interested in a single type of feature. It returns the a topologically ordered set of feature ids. For example, to print all catchments in the network:

for( auto catchment : network.filter('cat') ){
std::cout << catchment;
}
Definition network.hpp:22
Parameters
typeThe type of feature to filter for, i.e. 'cat', 'nex'
target_layerThe layer that filtered results should be in
orderWhat order to return results in
Returns
auto

References hy_features::identifiers::catchment, get_id(), get_sorted_index(), hy_features::identifiers::isCatchment(), hy_features::identifiers::isNexus(), layer_map, hy_features::identifiers::nexus, and hy_features::identifiers::seperator.

◆ filter() [2/2]

auto network::Network::filter ( std::string type,
SortOrder order = SortOrder::Topological )
inline

Provides a boost transform_iterator, filtered by type , to the topologically ordered graph vertex string id's.

This function is useful when only interested in a single type of feature. It returns the a topologically ordered set of feature ids. For example, to print all catchments in the network:

for( auto catchment : network.filter('cat') ){
std::cout << catchment;
}
Parameters
typeThe type of feature to filter for, i.e. 'cat', 'nex'
orderWhat order to return results in
Returns
auto

References hy_features::identifiers::catchment, get_id(), get_sorted_index(), hy_features::identifiers::isCatchment(), hy_features::identifiers::isNexus(), hy_features::identifiers::nexus, and hy_features::identifiers::seperator.

◆ get_destination_ids()

std::vector< std::string > Network::get_destination_ids ( const std::string & id)

Get the destination (downstream) ids (immediate neighbors) of all vertices with an edge from id.

Parameters
id
Returns
std::vector<std::string>

References begin(), descriptor_map, end(), get_id(), and graph.

◆ get_id()

std::string Network::get_id ( Graph::vertex_descriptor idx)

Get the string id of a given graph vertex_descriptor idx.

Parameters
idx
Returns
std::string
Exceptions
std::invalid_argumentif idx is not in the range of valid vertex descriptors [0, num_verticies)

References graph.

Referenced by filter(), filter(), get_destination_ids(), and get_origination_ids().

◆ get_origination_ids()

std::vector< std::string > Network::get_origination_ids ( const std::string & id)

Get the origination (upstream) ids (immediate neighbors) of all vertices with an edge connecting to id.

Parameters
id
Returns
std::vector<std::string>

References begin(), descriptor_map, end(), get_id(), and graph.

◆ get_sorted_index()

const NetworkIndexT & Network::get_sorted_index ( SortOrder order = SortOrder::Topological,
bool cache = true )
private

Get an index of the graph in a particular order.

Parameters
orderThe desired order
cacheNOT YET IMPLEMENTED. Whether to cache the generated index. Default is true.

References network::df_preorder_sort(), graph, tdfp_order, topo_order, and network::TransposedDepthFirstPreorder.

Referenced by filter(), and filter().

◆ headwaters()

IndexPair Network::headwaters ( )

An iterator pair (begin, end) of the network headwater features.

Returns
IndexPair

References headwaters_idx.

◆ init_indicies()

void Network::init_indicies ( )
private

Initializes the head/tailwater iterators after the underlying graph is constructed.

References begin(), end(), graph, headwaters_idx, tailwaters_idx, and topo_order.

Referenced by Network(), and Network().

◆ print_network()

void network::Network::print_network ( )
inline

Print a graphviz (text) representation of the network.

References graph.

◆ size()

std::size_t Network::size ( )

The number of features in the network (number of vertices)

Returns
std::size_t

References graph.

◆ tailwaters()

IndexPair Network::tailwaters ( )

An iterator pair (begin, end) of the network tailwater features.

Returns
IndexPair

References tailwaters_idx.

Member Data Documentation

◆ descriptor_map

std::unordered_map<std::string, Graph::vertex_descriptor> network::Network::descriptor_map
private

Mapping of identity to graph vertex descriptor.

Referenced by Network(), Network(), get_destination_ids(), and get_origination_ids().

◆ graph

Graph network::Network::graph
private

◆ headwaters_idx

NetworkIndexT network::Network::headwaters_idx
private

Vector of headwater features.

Referenced by headwaters(), and init_indicies().

◆ layer_map

std::unordered_map<std::string, long> network::Network::layer_map
private

Mapping of identifier to hydrofabric layer.

Referenced by Network(), and filter().

◆ tailwaters_idx

NetworkIndexT network::Network::tailwaters_idx
private

Vector of tailwater features.

Referenced by init_indicies(), and tailwaters().

◆ tdfp_order

NetworkIndexT network::Network::tdfp_order
private

Referenced by get_sorted_index().

◆ topo_order

NetworkIndexT network::Network::topo_order
private

Vector of topologically sorted features.

Referenced by begin(), end(), get_sorted_index(), and init_indicies().


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