Untitled
unknown
plain_text
2 years ago
1.4 kB
3
Indexable
// Function to build a port gateway void buildPortGateway(Node* node, const std::string& gatewayName) { Node* gateway = new Node(); gateway->name = gatewayName; gateway->id = node->id + 1; // Assign a unique ID for the gateway // Establish connection between the node and the gateway node->connections.push_back(gateway); gateway->connections.push_back(node); std::cout << "Port gateway '" << gatewayName << "' successfully built!" << std::endl; } // Function to build a bridge between two nodes void buildBridge(Node* node1, Node* node2) { // Check if the bridge already exists for (Node* connection : node1->connections) { if (connection == node2) { std::cout << "A bridge already exists between the given nodes!" << std::endl; return; } } // Establish connection between node1 and node2 node1->connections.push_back(node2); node2->connections.push_back(node1); std::cout << "Bridge successfully built between Node ID: " << node1->id << " and Node ID: " << node2->id << std::endl; } // Function to end the program and clean up resources void end(std::vector<Node*>& reticulum) { // Clean up nodes and connections for (Node* node : reticulum) { delete node; } reticulum.clear(); std::cout << "Program ended. Resources cleaned up." << std::endl; }
Editor is loading...