33 Edge(
int e0,
int e1,
int _len) :
36 bool operator==(
const Edge &rhs)
const {
37 return ((end[0] == rhs.end[0]) && (end[1] == rhs.end[1]));
45 void get_elist(
const std::vector<Edge> &edges, std::vector<int> &elist,
46 std::vector<int> &ecap);
54 AdjObj(
int otherend,
int index,
double _val) :
55 other_end(otherend), edge_index(index), val(_val) {}
61 bool operator==(
const AdjObj &rhs)
const 74 int degree()
const {
return neighbors.size(); }
84 AdjList(
int ncount,
const std::vector<Edge> &ref_elist);
87 template <
typename EndPt_type>
88 AdjList(
int ncount,
const std::vector<EndPt_type> &elist);
92 const std::vector<Edge> &ref_elist,
93 const std::vector<double> &ref_elist_caps,
94 const std::vector<int> &keep_indices);
101 bool connected(std::vector<int> &island,
int start_node);
104 void dfs(
int start_node, std::vector<int> &island);
110 for (
const AdjObj &a : nodelist[end0].neighbors)
111 if (a.other_end == end1)
116 AdjObj *find_edge(
int end0,
int end1)
118 for (
AdjObj &a : nodelist[end0].neighbors)
119 if (a.other_end == end1)
125 void add_edge(
int end0,
int end1,
int index,
double val);
130 std::vector<Node> nodelist;
143 std::vector<int>
delta_inds(
const std::vector<int> &node_list,
144 const std::vector<Edge> &edges,
148 std::vector<int>
delta_inds(
const std::vector<int> &node_list,
149 const std::vector<int> &elist,
162 template <
typename EndPt_type>
163 AdjList::AdjList(
int ncount,
const std::vector<EndPt_type> &elist)
try 164 : node_count(ncount), edge_count(elist.size()),
165 nodelist(
std::vector<
Node>(node_count))
167 for (
int i = 0; i < edge_count; ++i) {
168 const auto &e = elist[i];
170 nodelist[e.end[0]].neighbors.emplace_back(e.end[1], i, 0.0);
171 nodelist[e.end[1]].neighbors.emplace_back(e.end[0], i, 0.0);
173 }
catch (
const std::exception &e) {
174 std::cerr << e.what() <<
"\n";
175 throw std::runtime_error(
"AdjList EndPt_type constructor failed.");
Edge(int e0, int e1, int _len)
Construct by endpoints and length.
Definition: graph.hpp:33
void get_elist(const std::vector< Edge > &edges, std::vector< int > &elist, std::vector< int > &ecap)
Get a node-node elist representation of a list of edges.
bool removable
For use by certain erase-remove procedures.
Definition: graph.hpp:41
int edge_index
The index wrt a fixed Graph::Edge vector of (x, y).
Definition: graph.hpp:58
const AdjObj * find_edge(int end0, int end1) const
Get a pointer to the AdjObj with end points end0 and end1.
Definition: graph.hpp:108
Representing graph edges and costs.
Definition: graph.hpp:29
Utility functions, macros, and structures.
std::vector< AdjObj > neighbors
The nodes adjacent to this Node.
Definition: graph.hpp:75
A vertex in a Graph::AdjList graph.
Definition: graph.hpp:71
std::vector< int > delta_inds(const std::vector< int > &node_list, const std::vector< Edge > &edges, int ncount)
Cut set node_list, with graph specified by edges with ncount nodes.
int other_end
The node y in the notation above.
Definition: graph.hpp:57
The namespace for this project.
Definition: abc_nodesel.hpp:20
Representation of a graph as an adjacency list.
Definition: graph.hpp:80
Simple base class for storing edge of a graph as a sorted pair of nodes.
Definition: util.hpp:239
int len
The edge length.
Definition: graph.hpp:40
double val
Can represent length or some other value on the edge.
Definition: graph.hpp:59
Object used to represent adjacency in a Graph::AdjList.
Definition: graph.hpp:51
int mark
A value to be used by pricing/delta routines.
Definition: graph.hpp:76