17 template<
typename _node,
typename _edge,
template<
typename ...>
typename container_t,
typename ...Args>
23 template<
typename ... Argshere>
48 template<typename _neighborhood>
52 typedef typename neighborhood_t::edge_t
edge_t;
53 typedef typename neighborhood_t::node_t
node_t;
58 template<
typename ... Args>
83 std::vector<neighborhood_t> neighborhoods;
92 template<
typename graph_t,
typename policy_t>
95 typedef typename graph_t::node_t
node_t;
96 typedef typename graph_t::neighborhood_t::const_iterator
edge_iter_t;
104 std::vector<std::vector<edge_iter_t>>
paths;
127 std::vector<std::pair<node_t, edge_iter_t>>
previous;
133 void print_path_minimal(std::ostream& os,
node_t i, std::set<node_t>& nodes_printed)
const;
134 void print_path_minimal(std::ostream& os,
node_t i)
const;
135 void compute_distance();
136 void compute_paths();
137 template<
typename _graph,
typename _pol>
142 template<
typename neighborhood_t>
146 template<
typename graph_t,
typename policy_t>
150 #include "impl/Graph.ipp"
A directed graph.
Definition: Graph.hpp:49
void reserve_edges_per_node(const T &v)
Reserves v[i] many edges for node i.
neighborhood_t::edge_t edge_t
The edge type.
Definition: Graph.hpp:52
void print_name_labels(std::ostream &os) const
Prints names as .dot style labels to output stream.
neighborhood_t::node_t node_t
The node type.
Definition: Graph.hpp:53
std::function< std::string(node_t)> node_names
Function mapping node index to its name.
Definition: Graph.hpp:78
void draw_edge(node_t start, node_t end, Args &&... args)
Connects start->end. The arguments are forwarded to the edge constructor.
void reserve_nodes(size_t n)
...Reserves n many edges for all nodes
void reserve_edges_for_node(size_t num, node_t node)
Reserves num many edges for given node.
auto neighbors(node_t node) const -> const neighborhood_t &
The adjecency list of a node.
size_t number_of_nodes() const
void adjoin_nodes(size_t new_number_of_nodes)
Adds new nodes so that the total is new_number_of_nodes.
_neighborhood neighborhood_t
The neighborhood type.
Definition: Graph.hpp:51
The adjecency list of a node in a graph.
Definition: Graph.hpp:18
auto begin() const -> const_iterator
Starting iterator.
auto end() const -> const_iterator
Ending iterator.
_edge edge_t
Definition: Graph.hpp:21
void insert(node_t end, Argshere &&... args)
Insert node+edge in neighborhood.
_node node_t
The node type.
Definition: Graph.hpp:20
void reserve(size_t n)
Reserve number of edges.
The shortest paths from a collection of sources to all points in a graph.
Definition: Graph.hpp:93
std::vector< std::pair< node_t, edge_iter_t > > previous
previous[i]=(node,edge) where node is 1 step closer to the source and edge connects node to i
Definition: Graph.hpp:127
friend std::ostream & operator<<(std::ostream &, const ShortestPaths< _graph, _pol > &)
node_t root
The root (source) of the graph being considered.
Definition: Graph.hpp:130
ShortestPaths(const graph_t &G)
Constructor computes the shortest paths given the graph.
void compute_with_root(node_t new_root)
Compute all paths using given root.
std::vector< std::vector< edge_iter_t > > paths
The shortest paths from the sources to all nodes.
Definition: Graph.hpp:104
std::vector< size_t > distance_policy
The distance from a source to a node, computed by some policy (eg weight)
Definition: Graph.hpp:124
graph_t::neighborhood_t::const_iterator edge_iter_t
The iterator type used in the paths.
Definition: Graph.hpp:96
void print_path(std::ostream &os, node_t i) const
Print shortest path to node i to the output stream.
const graph_t & G
Constant reference to the graph.
Definition: Graph.hpp:121
bool disconnected(node_t) const
Checks if node is connected to any one of the sources.
std::vector< node_t > root_per_path
The source of each path.
Definition: Graph.hpp:107
graph_t::node_t node_t
The node type.
Definition: Graph.hpp:95
Everything in this library is under this namespace.
Definition: Box.hpp:9
std::ostream & operator<<(std::ostream &, const Chains< rank_t, diff_t > &)
Prints chain complex.
Constant iterator traversing edges with fixed start.
Definition: Graph.hpp:28
auto edge() const -> const edge_t &
auto operator++() -> const_iterator &
auto node() const -> node_t
The end node of the edge.