|
NuriKit v0.1.0b2
|
A subgraph of a graph. More...
#include <nuri/core/graph/subgraph.h>
Public Types | |
| using | graph_type = Graph<NT, ET> |
| using | parent_type = internal::const_if_t<is_const, graph_type> |
| using | node_data_type = NT |
| using | edge_data_type = ET |
| using | iterator = internal::SubNodeIterator<Subgraph, is_const> |
| using | node_iterator = iterator |
| using | const_iterator = internal::SubNodeIterator<Subgraph, true> |
| using | const_node_iterator = const_iterator |
| using | NodeRef = internal::SubNodeWrapper<Subgraph, is_const> |
| using | ConstNodeRef = internal::SubNodeWrapper<Subgraph, true> |
| using | edge_iterator = internal::SubEdgeIterator<Subgraph, is_const> |
| using | const_edge_iterator = internal::SubEdgeIterator<Subgraph, true> |
| using | EdgeRef = internal::SubEdgeWrapper<Subgraph, is_const> |
| using | ConstEdgeRef = internal::SubEdgeWrapper<Subgraph, true> |
| using | EdgesWrapper = internal::EdgesWrapper<Subgraph, is_const> |
| using | ConstEdgesWrapper = internal::EdgesWrapper<Subgraph, true> |
| using | adjacency_iterator = internal::SubAdjIterator<Subgraph, is_const> |
| using | const_adjacency_iterator = internal::SubAdjIterator<Subgraph, true> |
| using | AdjRef = internal::SubAdjWrapper<Subgraph, is_const> |
| using | ConstAdjRef = internal::SubAdjWrapper<Subgraph, true> |
| template<bool other_const> | |
| using | Other = Subgraph<NT, ET, other_const> |
Public Member Functions | |
| Subgraph (graph_type &&graph)=delete | |
| Subgraph (parent_type &graph) | |
| Construct an empty subgraph. | |
| template<bool other_const, std::enable_if_t< is_const &&!other_const, int > = 0> | |
| Subgraph (const Other< other_const > &other) | |
| Converting constructor to allow implicit conversion from a non-const subgraph to a const subgraph. | |
| template<bool other_const, std::enable_if_t< is_const &&!other_const, int > = 0> | |
| Subgraph (Other< other_const > &&other) noexcept | |
| Converting constructor to allow implicit conversion from a non-const subgraph to a const subgraph. | |
| template<bool other_const, std::enable_if_t< is_const &&!other_const, int > = 0> | |
| Subgraph & | operator= (const Other< other_const > &other) |
| Converting assignment operator to allow implicit conversion from a non-const subgraph to a const subgraph. | |
| template<bool other_const, std::enable_if_t< is_const &&!other_const, int > = 0> | |
| Subgraph & | operator= (Other< other_const > &&other) noexcept |
| Converting assignment operator to allow implicit conversion from a non-const subgraph to a const subgraph. | |
| bool | empty () const |
| Whether the subgraph is empty. | |
| int | size () const |
| Count number of nodes in the subgraph. | |
| int | num_nodes () const |
| Count number of nodes in the subgraph. | |
| int | num_edges () const |
| Count number of edges in the subgraph. | |
| void | update (internal::IndexSet &&nodes, internal::IndexSet &&edges) |
| Change the set of nodes and edges in the subgraph. | |
| void | update_nodes (internal::IndexSet &&nodes) noexcept |
| Change the set of nodes in the subgraph. | |
| void | update_edges (internal::IndexSet &&edges) noexcept |
| Change the set of edges in the subgraph. | |
| void | refresh_edges () |
| Make this graph an induced subgraph of the parent graph. | |
| void | clear () noexcept |
| Clear the subgraph. | |
| void | clear_edges () noexcept |
| Clear the edges. | |
| void | reserve_nodes (int num_nodes) |
| Reserve space for a number of nodes. | |
| void | reserve_edges (int num_edges) |
| Reserve space for a number of edges. | |
| void | add_node (int id) |
| Add a node to the subgraph. | |
| void | add_edge (int id) |
| Add an edge to the subgraph. Also adds the incident nodes. | |
| void | add_nodes (const internal::IndexSet &nodes) |
| Add nodes to the subgraph. | |
| void | add_edges (const internal::IndexSet &edges) |
| Add edges to the subgraph. Also adds the incident nodes. | |
| void | add_nodes_with_edges (const internal::IndexSet &nodes) |
| Add nodes to the subgraph, and update the edges. | |
| bool | contains_node (int id) const |
| Check if a node is in the subgraph. | |
| bool | contains_node (typename graph_type::ConstNodeRef node) const |
| Check if a node is in the subgraph. | |
| bool | contains_edge (int id) const |
| Check if an edge is in the subgraph. | |
| bool | contains_edge (typename graph_type::ConstEdgeRef edge) const |
| Check if an edge is in the subgraph. | |
| NodeRef | operator[] (int idx) |
| Get a node in the subgraph. | |
| ConstNodeRef | operator[] (int idx) const |
| Get a node in the subgraph. | |
| NodeRef | node (int idx) |
| Get a node in the subgraph. | |
| ConstNodeRef | node (int idx) const |
| Get a node in the subgraph. | |
| EdgeRef | edge (int idx) |
| Get an edge in the subgraph. | |
| ConstEdgeRef | edge (int idx) const |
| Get an edge in the subgraph. | |
| internal::const_if_t< is_const, NT > & | node_data (int idx) |
| Get data of a node in the subgraph. | |
| const NT & | node_data (int idx) const |
| Get data of a node in the subgraph. | |
| internal::const_if_t< is_const, ET > & | edge_data (int idx) |
| Get data of an edge in the subgraph. | |
| const ET & | edge_data (int idx) const |
| Get data of an edge in the subgraph. | |
| std::conditional_t< is_const, typename parent_type::ConstNodeRef, typename parent_type::NodeRef > | parent_node (int idx) |
| Get a parent node of a node in the subgraph. | |
| parent_type::ConstNodeRef | parent_node (int idx) const |
| Get a parent node of a node in the subgraph. | |
| std::conditional_t< is_const, typename parent_type::ConstEdgeRef, typename parent_type::EdgeRef > | parent_edge (int idx) |
| Get a parent edge of an edge in the subgraph. | |
| parent_type::ConstEdgeRef | parent_edge (int idx) const |
| Get a parent edge of an edge in the subgraph. | |
| iterator | find_node (int id) |
| Find a node with the given id. | |
| iterator | find_node (typename graph_type::ConstNodeRef node) |
| Find a node with the given id. | |
| const_iterator | find_node (int id) const |
| Find a node with the given id. | |
| const_iterator | find_node (typename graph_type::ConstNodeRef node) const |
| Find a node with the given id. | |
| edge_iterator | find_edge (int id) |
| Find an edge with the given id. | |
| edge_iterator | find_edge (typename graph_type::ConstEdgeRef edge) |
| Find an edge with the given id. | |
| const_edge_iterator | find_edge (int id) const |
| Find an edge with the given id. | |
| const_edge_iterator | find_edge (typename graph_type::ConstEdgeRef edge) const |
| Find an edge with the given id. | |
| void | erase_node (int idx) |
| Erase a node from the subgraph. Corresponding edges will also be removed. | |
| void | erase_node (ConstNodeRef node) |
| Erase a node from the subgraph. | |
| void | erase_edge (int idx) |
| Erase an edge from the subgraph. | |
| void | erase_edge (ConstEdgeRef edge) |
| Erase an edge from the subgraph. | |
| void | erase_nodes (const_iterator begin, const_iterator end) |
| Erase range of nodes from the subgraph. Corresponding edges will also be removed. | |
| void | erase_edges (const_edge_iterator begin, const_edge_iterator end) |
| Erase range of edges from the subgraph. | |
| void | erase_node_of (int id) |
| Erase a node with given id from the subgraph. Corresponding edges will also be removed. | |
| void | erase_node_of (typename graph_type::ConstNodeRef node) |
| Erase a node with given id from the subgraph. Corresponding edges will also be removed. | |
| void | erase_edge_of (int id) |
| Erase an edge with given id from the subgraph. | |
| void | erase_edge_of (typename graph_type::ConstEdgeRef edge) |
| Erase an edge with given id from the subgraph. | |
| template<class UnaryPred> | |
| void | erase_nodes_if (UnaryPred pred) |
| Erase matching nodes from the subgraph. Corresponding edges will also be removed. | |
| template<class UnaryPred> | |
| void | erase_edges_if (UnaryPred &&pred) |
| Erase matching edges from the subgraph. | |
| void | remap (const std::vector< int > &node_map, const std::vector< int > &edge_map) |
| Re-map node/edge ids. | |
| void | remap_nodes (const std::vector< int > &node_map) |
| Re-map node ids. | |
| void | remap_edges (const std::vector< int > &old_to_new) |
| Re-map edge ids. | |
| iterator | begin () |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| const_iterator | cbegin () const |
| const_iterator | cend () const |
| node_iterator | node_begin () |
| node_iterator | node_end () |
| const_node_iterator | node_begin () const |
| const_node_iterator | node_end () const |
| const_node_iterator | node_cbegin () const |
| const_node_iterator | node_cend () const |
| EdgesWrapper | edges () |
| ConstEdgesWrapper | edges () const |
| edge_iterator | edge_begin () |
| edge_iterator | edge_end () |
| const_edge_iterator | edge_begin () const |
| const_edge_iterator | edge_end () const |
| const_edge_iterator | edge_cbegin () const |
| const_edge_iterator | edge_cend () const |
| const std::vector< int > & | node_ids () const |
| Get all node ids in the subgraph. | |
| const std::vector< int > & | edge_ids () const |
| Get all edge ids in the subgraph. | |
| int | degree (int idx) const |
| Count in-subgraph neighbors of a node. | |
| edge_iterator | find_edge (ConstNodeRef src, ConstNodeRef dst) |
| Find edge between two nodes. | |
| const_edge_iterator | find_edge (ConstNodeRef src, ConstNodeRef dst) const |
| Find edge between two nodes. | |
| edge_iterator | find_edge (typename graph_type::ConstNodeRef src, typename graph_type::ConstNodeRef dst) |
| Find edge between two nodes. | |
| const_edge_iterator | find_edge (typename graph_type::ConstNodeRef src, typename graph_type::ConstNodeRef dst) const |
| Find edge between two nodes. | |
| adjacency_iterator | find_adjacent (ConstNodeRef src, ConstNodeRef dst) |
| Find adjacent node of a node. | |
| const_adjacency_iterator | find_adjacent (ConstNodeRef src, ConstNodeRef dst) const |
| Find adjacent node of a node. | |
| adjacency_iterator | adj_begin (int idx) |
| adjacency_iterator | adj_end (int idx) |
| const_adjacency_iterator | adj_begin (int idx) const |
| const_adjacency_iterator | adj_end (int idx) const |
| const_adjacency_iterator | adj_cbegin (int idx) const |
| const_adjacency_iterator | adj_cend (int idx) const |
| void | rebind (parent_type &parent) |
| Re-bind the subgraph to a new parent graph. | |
Static Public Member Functions | |
| static Subgraph | from_indices (parent_type &graph, internal::IndexSet &&nodes, internal::IndexSet &&edges) |
| Construct a subgraph with the given nodes and edges. | |
| static Subgraph | from_nodes (parent_type &graph, internal::IndexSet &&nodes) |
| Construct a subgraph with the given nodes and all edges connecting the nodes. | |
| static Subgraph | from_edges (parent_type &graph, internal::IndexSet &&edges) |
| Construct a subgraph with the given edges and all nodes connected to the edges. | |
Friends | |
| class | Subgraph< NT, ET, true > |
A subgraph of a graph.
| NT | node data type |
| ET | edge data type |
| is_const | whether the subgraph is const. This is to support creating subgraphs of const graphs. |
The subgraph is a non-owning view of a graph. A subgraph could be constructed by selecting nodes of the parent graph. The resulting subgraph will contain only the nodes and edges that are incident to the selected nodes.
The subgraph has very similar API to the graph. Here, we note major differences:
In all time complexity specifications, \(V\) and \(E\) are the number of nodes and edges in the parent graph, and \(V'\) and \(E'\) are the number of nodes and edges in the subgraph, respectively.
| using nuri::Subgraph< NT, ET, is_const >::adjacency_iterator = internal::SubAdjIterator<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::AdjRef = internal::SubAdjWrapper<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::const_adjacency_iterator = internal::SubAdjIterator<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::const_edge_iterator = internal::SubEdgeIterator<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::const_iterator = internal::SubNodeIterator<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::const_node_iterator = const_iterator |
| using nuri::Subgraph< NT, ET, is_const >::ConstAdjRef = internal::SubAdjWrapper<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::ConstEdgeRef = internal::SubEdgeWrapper<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::ConstEdgesWrapper = internal::EdgesWrapper<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::ConstNodeRef = internal::SubNodeWrapper<Subgraph, true> |
| using nuri::Subgraph< NT, ET, is_const >::edge_data_type = ET |
| using nuri::Subgraph< NT, ET, is_const >::edge_iterator = internal::SubEdgeIterator<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::EdgeRef = internal::SubEdgeWrapper<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::EdgesWrapper = internal::EdgesWrapper<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::graph_type = Graph<NT, ET> |
| using nuri::Subgraph< NT, ET, is_const >::iterator = internal::SubNodeIterator<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::node_data_type = NT |
| using nuri::Subgraph< NT, ET, is_const >::node_iterator = iterator |
| using nuri::Subgraph< NT, ET, is_const >::NodeRef = internal::SubNodeWrapper<Subgraph, is_const> |
| using nuri::Subgraph< NT, ET, is_const >::Other = Subgraph<NT, ET, other_const> |
| using nuri::Subgraph< NT, ET, is_const >::parent_type = internal::const_if_t<is_const, graph_type> |
|
delete |
|
inline |
Construct an empty subgraph.
| graph | The parent graph |
|
inline |
Converting constructor to allow implicit conversion from a non-const subgraph to a const subgraph.
| other | The non-const subgraph |
|
inlinenoexcept |
Converting constructor to allow implicit conversion from a non-const subgraph to a const subgraph.
| other | The non-const subgraph |
|
inline |
Add an edge to the subgraph. Also adds the incident nodes.
| id | The id of the edge to add |
|
inline |
Add edges to the subgraph. Also adds the incident nodes.
| edges | The new set of edges |
|
inline |
Add a node to the subgraph.
| id | The id of the node to add |
|
inline |
Add nodes to the subgraph.
| nodes | The new set of nodes |
|
inline |
Add nodes to the subgraph, and update the edges.
| nodes | The new set of nodes |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
Clear the subgraph.
|
inlinenoexcept |
Clear the edges.
|
inline |
Check if an edge is in the subgraph.
| id | the id of the edge to check |
|
inline |
Check if an edge is in the subgraph.
| edge | The edge to check |
|
inline |
Check if a node is in the subgraph.
| id | the id of the node to check |
|
inline |
Check if a node is in the subgraph.
| node | The node to check |
|
inline |
Count in-subgraph neighbors of a node.
| idx | The index of the node |
|
inline |
Get an edge in the subgraph.
| idx | The index of the edge to get |
|
inline |
Get an edge in the subgraph.
| idx | The index of the edge to get |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get data of an edge in the subgraph.
| idx | The index of the edge to get |
|
inline |
Get data of an edge in the subgraph.
| idx | The index of the edge to get |
|
inline |
|
inline |
|
inline |
Get all edge ids in the subgraph.
|
inline |
|
inline |
|
inline |
Whether the subgraph is empty.
|
inline |
|
inline |
|
inline |
Erase an edge from the subgraph.
| edge | The edge to erase |
|
inline |
Erase an edge from the subgraph.
| idx | The index of the edge to erase |
|
inline |
Erase an edge with given id from the subgraph.
| id | The id of the edge to erase |
|
inline |
Erase an edge with given id from the subgraph.
| edge | The parent edge to erase |
|
inline |
Erase range of edges from the subgraph.
| begin | Iterator pointing to the first edge to erase |
| end | Iterator pointing to the edge after the last edge to erase |
|
inline |
Erase matching edges from the subgraph.
| UnaryPred | Type of the unary predicate |
| pred | Unary predicate that returns true for edges to erase |
|
inline |
Erase a node from the subgraph.
| node | The node to erase |
|
inline |
Erase a node from the subgraph. Corresponding edges will also be removed.
| idx | The index of the node to erase. |
|
inline |
Erase a node with given id from the subgraph. Corresponding edges will also be removed.
| id | The id of the node to erase |
|
inline |
Erase a node with given id from the subgraph. Corresponding edges will also be removed.
| node | The parent node to erase |
|
inline |
Erase range of nodes from the subgraph. Corresponding edges will also be removed.
| begin | Iterator pointing to the first node to erase |
| end | Iterator pointing to the node after the last node to erase |
|
inline |
Erase matching nodes from the subgraph. Corresponding edges will also be removed.
| UnaryPred | Type of the unary predicate |
| pred | Unary predicate that returns true for nodes to erase |
|
inline |
Find adjacent node of a node.
| src | The source atom |
| dst | The destination atom |
|
inline |
Find adjacent node of a node.
| src | The source atom |
| dst | The destination atom |
|
inline |
Find edge between two nodes.
| src | The source atom |
| dst | The destination atom |
|
inline |
Find edge between two nodes.
| src | The source atom |
| dst | The destination atom |
|
inline |
Find an edge with the given id.
| id | The id of the edge to find |
|
inline |
Find an edge with the given id.
| id | The id of the edge to find |
|
inline |
Find an edge with the given id.
| edge | The edge to find |
|
inline |
Find an edge with the given id.
| edge | The edge to find |
|
inline |
Find edge between two nodes.
| src | The parent node of one node |
| dst | The parent node of the other node |
|
inline |
Find edge between two nodes.
| src | The index of one node |
| dst | The index of the other node |
|
inline |
Find a node with the given id.
| id | The id of the node to find |
|
inline |
Find a node with the given id.
| id | The id of the node to find |
|
inline |
Find a node with the given id.
| node | The node to find |
|
inline |
Find a node with the given id.
| node | The node to find |
|
inlinestatic |
Construct a subgraph with the given edges and all nodes connected to the edges.
| graph | The parent graph |
| edges | The set of edges |
|
inlinestatic |
Construct a subgraph with the given nodes and edges.
| graph | The parent graph |
| nodes | The set of nodes |
| edges | The set of edges |
|
inlinestatic |
Construct a subgraph with the given nodes and all edges connecting the nodes.
| graph | The parent graph |
| nodes | The set of nodes |
|
inline |
Get a node in the subgraph.
| idx | The index of the node to get |
|
inline |
Get a node in the subgraph.
| idx | The index of the node to get |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get data of a node in the subgraph.
| idx | The index of the node to get |
|
inline |
Get data of a node in the subgraph.
| idx | The index of the node to get |
|
inline |
|
inline |
|
inline |
Get all node ids in the subgraph.
|
inline |
Count number of edges in the subgraph.
|
inline |
Count number of nodes in the subgraph.
|
inline |
Converting assignment operator to allow implicit conversion from a non-const subgraph to a const subgraph.
| other | The non-const subgraph |
|
inlinenoexcept |
Converting assignment operator to allow implicit conversion from a non-const subgraph to a const subgraph.
| other | The non-const subgraph |
|
inline |
Get a node in the subgraph.
| idx | The index of the node to get |
|
inline |
Get a node in the subgraph.
| idx | The index of the node to get |
|
inline |
Get a parent edge of an edge in the subgraph.
| idx | The index of the edge to get |
|
inline |
Get a parent edge of an edge in the subgraph.
| idx | The index of the edge to get |
|
inline |
Get a parent node of a node in the subgraph.
| idx | The index of the node to get |
|
inline |
Get a parent node of a node in the subgraph.
| idx | The index of the node to get |
|
inline |
Re-bind the subgraph to a new parent graph.
| parent | The new parent graph to bind. |
|
inline |
Make this graph an induced subgraph of the parent graph.
Replace the current set of edges with the set of edges connecting the current set of nodes.
|
inline |
Re-map node/edge ids.
| node_map | A vector that maps old node ids to new node ids, so that old_to_new[old_id] = new_id. If old_to_new[old_id] < 0, then the node is removed from the subgraph. |
| edge_map | A vector that maps old edge ids to new edge ids, so that old_to_new[old_id] = new_id. If old_to_new[old_id] < 0, then the edge is removed from the subgraph. |
|
inline |
Re-map edge ids.
| old_to_new | A vector that maps old edge ids to new edge ids, so that old_to_new[old_id] = new_id. If old_to_new[old_id] < 0, then the edge is removed from the subgraph. |
|
inline |
Re-map node ids.
| node_map | A vector that maps old node ids to new node ids, so that old_to_new[old_id] = new_id. If old_to_new[old_id] < 0, then the node is removed from the subgraph. |
|
inline |
Reserve space for a number of edges.
| num_edges | The number of edges to reserve space for |
|
inline |
Reserve space for a number of nodes.
| num_nodes | The number of nodes to reserve space for |
|
inline |
Count number of nodes in the subgraph.
|
inline |
Change the set of nodes and edges in the subgraph.
| nodes | The new set of nodes. |
| edges | The new set of edges. |
|
inlinenoexcept |
Change the set of edges in the subgraph.
| edges | The new set of edges. All nodes connected to the edges will be automatically added. |
|
inlinenoexcept |
Change the set of nodes in the subgraph.
| nodes | The new set of nodes. Edges will be automatically updated. |
|
friend |