36 unordered_map<Index, GraphNode> nodes) {
37 for (
const Index vertex : vertices) {
38 if (nodes.count(vertex) == 0) {
45Graph::Graph(vector<Edge> edges, unordered_map<Index, GraphNode> nodes) {
49 "A node must exist for every vertex.");
51 for (
const pair<Index, GraphNode> id_and_node :
nodes_) {
60 return id_.compare(graph.
id_);
66 vector<pair<Index, GraphNode>> isolated_nodes;
69 for (
const Index vertex : vertices_degree_0) {
70 pair<Index, GraphNode> id_and_node{vertex,
nodes_.at(vertex)};
71 isolated_nodes.push_back(id_and_node);
73 return isolated_nodes;
78 vector<pair<Index, GraphNode>> neigh_ids_and_nodes;
79 for (
const Index& neigh_vert : neigh_vertices) {
81 pair<Index, GraphNode>(neigh_vert,
nodes_.at(neigh_vert));
82 neigh_ids_and_nodes.push_back(id_and_node);
84 return neigh_ids_and_nodes;
88 assert(
nodes_.count(vertex) &&
"Can only set a node that already exists");
89 nodes_[vertex] = graph_node;
94 setNode(id_and_node.first, id_and_node.second);
98 assert(
nodes_.count(vertex));
103 vector<pair<Index, GraphNode>> vec_nodes;
104 for (
const pair<const Index, GraphNode>& id_and_node :
nodes_) {
105 vec_nodes.push_back(id_and_node);
111 vector<Index> junctions;
113 for (
Index degree = 3; degree <= max_degree; ++degree) {
115 junctions.insert(junctions.end(), vertices.begin(), vertices.end());
123 assert(
nodes_.size() == 0);
124 for (
const pair<const Index, GraphNode>& id_and_node : graph.
nodes_) {
125 this->
nodes_[id_and_node.first] = id_and_node.second;
132 string struct_Id_temp =
"";
133 for (
const pair<Index, GraphNode>& id_and_node : nodes) {
134 struct_Id_temp.append(id_and_node.second.getStringId());
136 id_ = struct_Id_temp;
144 if (
nodes_.count(vertex)) {
147 throw invalid_argument(
148 "vertex does not exist within the graph the degree is "
156 if (
nodes_.count(vertex)) {
171 os <<
"Graph" << endl;
172 for (
const pair<const Index, GraphNode>& id_and_node : graph.
nodes_) {
173 os <<
"Node " << id_and_node.first << endl;
174 os << id_and_node.second << endl;
180 const pair<Index, GraphNode>& id_and_node2) {
181 string str1_Id = id_and_node1.second.getStringId();
182 return str1_Id.compare(id_and_node2.second.getStringId()) < 0;
base class for all analysis tools